【发布时间】:2013-12-04 05:49:21
【问题描述】:
我有全屏 MapViewController 和 LisViewController,它们显示在 popover 中。所以 ListViewController 是TableView,我需要通过单击单元格显示不同点的标注(在表格的行中表示)。目前我无法解决这个问题..
在我已经实现的 listViewController 中
// LisViewController.h
@protocol ListViewControllerDelegate <NSObject>
- (void)showCalloutForObjectId:(id) objectId;
@end
@interface ListViewController : UITableViewController
@property (nonatomic, strong) id delegate;
@end
// ListViewController.m
- (id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder: aDecoder];
if (self) {
self.delegate = [MapViewController new]; // I BELIEVE THE PROBLEM IS HERE - CAN'T GET THE INSTANCE OF THE PRESENT VIEW CONTROLLER
}
return self;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary * data = [self.dataSet dataFromIndex: indexPath.row];
if ([self.delegate respondsToSelector:@selector(showCalloutForObjectId:)])
{
[self.delegate showCalloutForObjectId: data[@"object_id"]];
}
}
所以我的 MapViewController 中的方法永远不会被调用 - 有什么帮助吗?
【问题讨论】:
-
[MapViewController new]-new是 MapViewController 中的一个方法吗?据我了解,您想通过关闭ListViewController来从ListViewController导航到MapViewController,这是一个弹出窗口,并根据ListViewController中的选定单元格通过MapViewController在地图上显示一些东西 - 对吧?可以发MapViewController的代码吗?
标签: ios objective-c uiviewcontroller delegates