【发布时间】:2012-12-04 03:41:13
【问题描述】:
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath];
return cell.bounds.size.height;
}
有什么缺点?
我改了
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.bounds.size.height;
}
【问题讨论】:
-
我不认为第一个是合法的Objective-C语法。
-
(我不确定哪一个是个好主意。)
-
这个问题和声明
tableView:cellForRowAtIndexPath:方法有什么关系? -
@HotLicks 第一个很好(语法上)。
UITableView有一个方法可以直接获取这样的单元格。 -
@rmaddy -- 好的,这是有道理的 -- 不同类的两种不同方法。乍一看,OP 似乎试图将属性语法与常规方法调用语法混合在一起。
标签: objective-c uitableview xcode4.5