tableView代理函数里边 heightForRowAtIndexPath 这个函数反复调用
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row==1) {
NSLog(@"=======");
}
return 50;
}
2015-07-28 14:45:17.677 play[4500:193867] =======
2015-07-28 14:45:17.678 play[4500:193867] =======
2015-07-28 14:45:17.679 play[4500:193867] =======
2015-07-28 14:45:17.681 play[4500:193867] =======
光是indexPath.row=1这里就反复调用了四次。
找人解答说heightForRowAtIndexPath这个函数因为需要调用好多次,所以有个保护机制,每次初始化的时候就会调用一次。
_myTableView.estimatedRowHeight=10;加上这一句话,就可以进行优化。