简体   繁体   中英

Tableview Cell size not changing? Swift

I dragged an dropped a table view Controller from the object library and changed the cell's row height to 300.However , when I run it in the simulator , the cell remains the same standard size.Why is this?

Images : 在此输入图像描述 在此输入图像描述

Constraints : 在此输入图像描述

Output : 在此输入图像描述

In Storyboard, if you know the cell height, set the Table View's Row Height property on the Size Inspector tab, not the cell's:

UITableView的Size Inspector页面

You can set custom row height example add ;

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat 
{
    return 100.0;//Your custom row height
}
  1. Make sure you have given all the constraints in the cell . They have to be connected from top to bottom.

  2. Make sure that the class of content view inside the custom cell is UIView .(I have done the same mistake )

    press content view -> see identity inspector on right -> class should be UI view . 自定义单元格元素

使用tableview的委托并设置heightforrowatindexpath方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM