iOS: Dynamic Height For UITableViewCell

前端 未结 3 369
故里飘歌
故里飘歌 2020-12-20 21:43

I\'m using iOS9 XCode7 I need to change the height of cell Dynamically according to labelText Height

I have used:

self.tableView.ro         


        
3条回答
  •  粉色の甜心
    2020-12-20 22:07

    try this. it is so simple.

    set this height in heightForRowAtIndexPath method

      float vendorNameHeight = [vendorNameLbl.text heigthWithWidth:width andFont:[UIFont fontWithName:@"Signika-Light" size:21.0]];
    

    then

      UILabel*vendorNameLbl=[[UILabel alloc]initWithFrame:CGRectMake( 13, 11, 100, 22)];
      vendorNameLbl.numberOfLines = 0;
      [vendorNameLbl sizeToFitVertically];
    

提交回复
热议问题