Saturday 15 August 2015

iphone - Get the width of the cell in the heightForRowAtIndexPath method -


This may be a simple question, but I have searched for hours but was unable to find the answer.

Is

heightForRowAtIndexPath method in UITableView method to get the width of the cell?

The reason is that I need to calculate the height of using NSAttributedString BoundingRectWithSize and obstruct the width of the cell.

Currently I'm calculating it in the cellForRowAtIndexPath method and then reloading the row.

This is causing every row to be refreshed after calculating its height, which is not a very good user experience.

Do I have both heightForRowAtIndexPath UITableView , both grouped and plain.

In grouped table views, the number of cells is smaller than the width of the table view, which means that You should get t he width in your -cellForRowAtIndexPath: method to NSLog or NSLog (@ "% f", cell.contentView.frame.size.width) By running; . You can then use it to determine the height.

There are cells in the table table that have the same width UITableView , and therefore, you can use the width of the table view i.e. the self.tableView Frame.size.width .

Anything else can be found here:

No comments:

Post a Comment