Open Daemon-Devarshi opened 9 years ago
I have the same problem. Did you sort this out?
I have a ugly solution, but worked.
CGFloat textWith = [self.valueLabel.text re_sizeWithFont:self.valueLabel.font].width;
const CGFloat maxTextWith = 200.f;
const CGFloat margin = 16.f;
[self layoutDetailView:self.valueLabel minimumWidth:textWith];
[self layoutDetailView:self.placeholderLabel minimumWidth:[self.placeholderLabel.text re_sizeWithFont:self.placeholderLabel.font].width];
if (textWith > maxTextWith) {
self.valueLabel.frame = CGRectMake(self.contentView.frame.size.width - maxTextWith - margin, self.valueLabel.frame.origin.y, maxTextWith, self.valueLabel.frame.size.height);
}
In my app I am getting a long string from server which I am assigning to
valueLabel
, once assigned it is getting overlapped over other labels/ components in the cell, attaching the screen-shot for your reference:This problem can be reproduced in sample app by hardcoding a string in
layoutSubviews (RETableViewPickerCell class)
, as shown below:On debugging I found that
re_sizeWithFont:
method inNSString (RETableViewManagerAdditions)
category is returning a long width value (~1788), because of which inlayoutDetailView:minimumWidth:
method inRETableViewCell
class, program counter is going inside below if condition:Results thus obtained are:
I think we got some clue over here ;-) (hint: check value of x)
Note: If I comment above 'if' condition then this problem does not occur.
Kindly suggest how can I resolve this issue? I think commenting
if
condition may break some other functionality.