I'm tried to di开发者_如何学运维splay the Title Data in the Tableview Cell it displayed but partially (...) i want to display full title in the table cell may be in two or three line i used customize cell and use the label and set label property but still data displayed partially
titleLabel.text = aNewsInfo.title;
Can any one suggest me the way to overcome this prob...
Thanks in Advance...
Try this code:
myLabel.lineBreakMode = UILineBreakModeWordWrap;
myLabel.numberOfLines = 2; // 2 lines ; 0 - dynamical number of lines
myLabel.text = @"Lorem ipsum dolor sit\namet...";
Maybe you can try:
[titleLabel sizeToFit];
And the you need to adjust the height of the cell with:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
The label's property needs to be set
adjustsFontSizeToFitWidth
A Boolean value indicating whether the font size should be reduced in order to fit
the title string into the label’s bounding rectangle.
@property(nonatomic) BOOL adjustsFontSizeToFitWidth
And
numberOfLines
The maximum number of lines to use for rendering text.
@property(nonatomic) NSInteger numberOfLines
Discussion
This property controls the maximum number of lines to use in order to fit the label’s text into its bounding rectangle. The default value for this property is 1. To remove any maximum limit, and use as many lines as needed, set the value of this property to 0.
If you constrain your text using this property, any text that does not fit within the maximum number of lines and inside the bounding rectangle of the label is truncated using the appropriate line break mode.
When the receiver is resized using the sizeToFit method, resizing takes into account the value stored in this property. For example, if this property is set to 3, the sizeToFit method resizes the receiver so that it is big enough to display three lines of text.
Hi try to add label in your cellforRow method
CGSize labelsize;
UILabel *commentsTextLabel = [[UILabel alloc] init];;
commentsTextLabel.tag =50;
[commentsTextLabel setNumberOfLines:0];
[commentsTextLabel setBackgroundColor:[UIColor clearColor]];
NSString *text=[@"dasdasdasdasfasfasfasfasfasfsafasfsafasfasfasfasfsafsafasfasfsaf"];
[commentsTextLabel setFont:[UIFont fontWithName:@"Helvetica"size:14]];
labelsize=[text sizeWithFont:commentsTextLabel.font constrainedToSize:CGSizeMake(268, 2000.0) lineBreakMode:UILineBreakModeWordWrap];
commentsTextLabel.frame=CGRectMake(10, 24, 268, labelsize.height);
[cell.contentView addSubview:commentsTextLabel];
[commentsTextLabel release];
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGSize labelsize;
UILabel * textDesc1 = [[UILabel alloc] init];
[textDesc1 setNumberOfLines:0];
textDesc1.text=[@"dasdasdasdasfasfasfasfasfasfsafasfsafasfasfasfasfsafsafasfasfsaf"];
[textDesc1 setFont:[UIFont fontWithName:@"Helvetica" size:14.0]];
labelsize=[textDesc1.text sizeWithFont:textDesc1.font constrainedToSize:CGSizeMake(268, 2000.0) lineBreakMode:UILineBreakModeWordWrap];
labelsize.height=labelsize.height+35;
[textDesc1 release];
return (CGFloat)labelsize.height;
}
精彩评论