How do I read a UITableViewCell (subclass)'s height from a NIB?

后端 未结 2 1396
悲&欢浪女
悲&欢浪女 2021-01-18 06:02

I have a UITableViewCell (really a subclass) defined in a NIB. In the NIB I\'ve set the frame height to 183, I also set the \"Row Height\" to 183 and ticked off custom.

2条回答
  •  既然无缘
    2021-01-18 06:38

    First UITableViewDelegate method, which gets called is heightForRowAtIndexPath not the UITableViewDataSource method, cellForRowAtIndexPath.

    You can get your custom cell height only in cellForRowAtIndexPath, where you alloc-init that cell. So, it won't consider custom cell height over here.

    It will take the height for the cell which is mentioned in heightForRowAtIndexPath method only. As it gets called first.

提交回复
热议问题