开发者

UITableViewCell returns 44px height when set higher

开发者 https://www.devze.com 2023-01-13 18:07 出处:网络
I\'m setting the height of my UITableViewCell as part of the method heightForRowAtIndexPath:. It\'s working fine, I can see the variable cell heights when the app runs.

I'm setting the height of my UITableViewCell as part of the method heightForRowAtIndexPath:. It's working fine, I can see the variable cell heights when the app runs.

However, as part of creating the content in the cell using cellForRowAtIndexPath, I would l开发者_StackOverflowike to position an image in a certain place depending on the height of the cell.

When trying to access the cell's height, I always get a result of 44px, despite the height being set previously correctly in the heightForRowAtIndexPath method.

I'm using cell.frame.size.height or cell.bounds.size.height - I get the same result. Any ideas why the cell (which is a UITableViewCell) is returning the default height? Does it apply the height from the previous method after I have setup the contents?


To get the height, just call your own method, passing in tableView and indexPath:

CGFloat height=[self tableView:tableView heightForRowAtIndexPath:indexPath];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号