简体   繁体   English

为什么在以下实例方法上收到“冲突类型”警告?

[英]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.

相关问题 为什么我在这里收到“找不到实例方法”消息? - Why am I getting a an 'instance method not found' message here? 为什么我在XCode中收到过时的警告 - Why am I getting a deprecated warning in XCode 定义方法后,为什么会收到“无法识别的选择器发送到实例”错误? - Why am I getting an “unrecognised selector sent to instance” error when I have defined the method? 为什么我收到有关我的应用程序委托和CLLocationManageDelegate的警告? - Why am I getting this warning about my app delegate and CLLocationManageDelegate? 为什么我收到警告“找到名为“ center”的多个方法” - Why am I am getting the warning “Multiple methods named 'center' found” 为什么会出现“找不到预期的吸气剂方法”? - Why am I getting “Expected getter method not found”? 我在Xcode for iOS中得到了“枚举类型的隐式转换”警告,我不知道为什么 - I am getting an “Implicit conversion from enumeration type” warning in Xcode for iOS and I don't know why 更改UIAlertView的背景颜色,我得到警告:找不到-setContents方法 - changing background color of UIAlertView , I am getting Warning : No -setContents method found 为什么我从Xcode收到此警告? iOS代码似乎很好 - Why am I getting this warning from Xcode? The iOS code seems fine 为什么我得到的ViewController实例与推送到navigationController的实例不同? - Why am I getting a different instance of a ViewController than the one I pushed onto the navigationController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM