[英]Why am I getting a “Conflicting types” warning on the below instance method?
I have the below code 我有以下代码
- (UITableViewCell *)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[[cell textLabel] setFont:[UIFont systemFontOfSize:10.0]];
return cell;
}
For some reason, I'm getting the following error: 由于某种原因,我收到以下错误:
warning: conflicting types for '-(UITableViewCell *)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath'
警告:'-(UITableViewCell *)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath'的类型冲突
Does anyone have any idea what might be causing this? 有谁知道这可能是什么原因?
- (void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
I guess it should be void according to Apple. 根据苹果公司的说法,我认为它应该是无效的。
The return type for that method should be void
. 该方法的返回类型应该为
void
。 The method doesn't return a cell, it simpoly informs you that it is going to be displayed. 该方法不会返回单元格,它会通过simpoly通知您它将要显示。 The particular cell being displayed is passed as one of the methods parameters.
显示的特定单元格作为方法参数之一传递。 You don't need to return it.
您不需要将其退回。 You can just set the font, and let it carry on.
您可以只设置字体,然后继续进行。
You use the wrong method. 您使用了错误的方法。 Use
采用
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
instead of yours. 而不是你的。 Than it won't show that warning.
比它不会显示该警告。 ;-)
;-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.