I wand to know the content of the cell when returning the heightForRowAtIndexPath. In this function how do I get the cell object?
- (CGFloat) tableView:(UITa
I don't think you can or you should. You'll need to determine from indexPath which data you will be displaying in the corresponding cell and thus calculate the needed height of the cell.
So you'll need to write some code to get from indexPath to the right data in your data model.
The cell hasn't been created when heightForRowAtIndexPath:
is called, so there's no way to "get" a cell. Instead, look at your model and determine the height of the cell that way.
If you're concerned about long strings and needing more vertical space in your cell, consider using sizeWithFont:forWidth:lineBreakMode:
. Docs here: https://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html
Call self (the delegate) rather than the tableView itself.
id cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
uitableviewcell *ce=[self.view viewwithtag:indexPath.row];
it returns the cell object.
Use: func dequeueReusableCellWithIdentifier(identifier: String) -> AnyObject?
of UITableView
.
Don't use: func dequeueReusableCellWithIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath) -> AnyObject
Possible Reason: heightForRowAtIndexPath
gets called before cellForRowAtIndexPath
and this method uses the index path to perform additional configuration based on the cell’s position in the table view. But since, there is still no cell yet, hence it goes to infinite loop I think.