【发布时间】:2011-12-10 23:23:02
【问题描述】:
我已将我正在编写的应用程序转换为 ios 5,然后使用内置工具将其转换为使用自动引用计数。 ios 5 没有问题,但在 ARC 转换后,我的大多数委托调用似乎都不起作用。例如,我有一个 UITableViewController 的子类,其 .h 文件如下所示:
@interface UITableVCSubclass : UITableViewController <UITableViewDelegate, ... >
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
...
@end
表格视图委托方法 tableView:didSelectRowAtIndexPath: 当我选择表格的一行时不再被调用。如果检查了 self.tableview.delegate == self,它会这样做。任何想法为什么这已经停止工作?
【问题讨论】:
-
能否提供您的 UITableViewDelegate 方法的实现(如果有):-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;
-
最初没有 willSelectRowAtIndexPath: 方法。我添加了以下内容只是为了看看它是否会被调用:'- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"willSelectRowAtIndexPath called");返回零; }' 。 . .它没有被调用。
-
tableView.delegate => self 连接是通过编程方式定义的,还是在 Interface Builder 中定义的?
-
你是用了ARC转换工具,还是自己改了类?
-
我没有使用界面生成器,tableView.delegate => self 由 UITableViewController 类自动完成。我使用了 ARC 转换工具。
标签: objective-c ios uitableview ios5 automatic-ref-counting