ios - Multiple lines of a label in a custom UITableviewCell -
i have searched around tip problem. cannot find solution this.
i have made subclass of uitableviewcell (feedcell). 1 image , 2 labels. problem label need multiline not show multilines.
i use autolayot.
this app display users twitterfeed.
my code:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; feedcell *tweetcell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (tweetcell == nil) { tweetcell = [[feedcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; [tweetcell.tweettext setnumberoflines:0]; [tweetcell.tweettext setlinebreakmode:nslinebreakbywordwrapping]; [tweetcell.tweettext setfont:[self fontforcell] ]; } nsdictionary *tweet = _datasource[[indexpath row]]; nsstring *tweetstring = [tweet valueforkey:@"text"]; tweetcell.name.text =[tweet valueforkeypath:@"user.name"]; [tweetcell.tweettext settext:tweetstring]; return tweetcell;
}
i have set heigthforrowatindexpath:
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { nsdictionary *tweet = _datasource[[indexpath row]]; nsstring *thetext=[tweet valueforkey:@"text"]; uifont *cellfont = [self fontforcell]; cgsize constraintsize = cgsizemake(280.0f, maxfloat); cgsize labelsize = [thetext sizewithfont:cellfont constrainedtosize:constraintsize linebreakmode:nslinebreakbywordwrapping]; return labelsize.height + 20;
}
the problem tweet cell.tweettext not show multilines. have not tried cellstyle (i use custom cellstyle).
any tip anyone?
for mutiline use following:
tweetcell.tweettext.numberoflines = 0; [tweetcell.tweettext sizetofit];
for testing purpose set height of row 46.0f in following method:
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{
i not height issue fixed did give me uilabel multiple lines
Comments
Post a Comment