【发布时间】:2011-02-16 09:53:58
【问题描述】:
我有一个 UITabBarController,它的一个选项卡上有一个 UINavigationController。然后 UINavigationController 将自定义 UIViewController 作为其主视图。
基于由自定义 UIViewController 中的按钮触发的 IBAction,我将 UITableView 控制器推送到 UINavigationController 堆栈,就像这样。 (注意:这些只是实际代码的 sn-ps)。
主 UIViewController 的头文件:
@interface ATMs : UIViewController <CLLocationManagerDelegate, NSFetchedResultsControllerDelegate, MKMapViewDelegate> {
}
- (IBAction) showLocationList;
@end
主 UIViewController 的实现文件:
@implementation ATMs
- (void)showLocationList {
LocationList *locationTableController = [[LocationList alloc] initWithNibName:@"LocationList" bundle:nil];
[self.navigationController pushViewController:locationTableController animated:YES];
[locationTableController release];
}
locationTableController 视图控制器对 Core Data 进行获取对象列表并将它们显示在表格上。当用户选择一行时,我希望发生以下事情:
- 将
locationTableController弹出导航控制器,以便我的ATMs视图控制器可见 - 调用
ATMs中的方法,传入locationTableController中点击的行所代表的对象
我试图通过在showLocationList 中使用[locationTableController setDelegate:self]; 来做到这一点,就在我alloc UITableViewController 的下方,并将UITableViewDelegate 添加到ATMs 的标题中。
但是当我执行上述操作时,我收到一个构建错误,指出locationTableController 可能无法响应setDelegate。
【问题讨论】:
标签: iphone cocoa-touch ios4