:改变加载顺序或者说白计算cell高度再让加载heightForRowAtIndexPath;
二:直接heightForRowAtIndexPath计算做判断直接返应高度
第种实例:
UITableView设置单元格高度
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {return64;}
// Somewhere
in your header:
NSIndexPath
*selectedCellIndexPath;
// And in the
implementation file:-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
selectedCellIndexPath
= indexPath;//Forces the table view to call heightForRowAtIndexPath[tableViewreloadRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];}-(CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {//Note: Some operations like calling [tableView
cellForRowAtIndexPath:indexPath]//will call heightForRow and thus create a stack overflow
if(selectedCellIndexPath !=nil
&& [selectedCellIndexPath
compare:indexPath] == NSOrderedSame){return128;}else{return64;}}reloadRowsAtIndexPaths重新调用heightForRowAtIndexPath使单元格改变高度
reloadRowsAtIndexPaths3.0.存储NSIndexPath原能堆栈溢情况
鹅,鹅,鹅