【发布时间】:2013-07-09 18:05:19
【问题描述】:
我是 iOS 编程新手。我用 MKMapView 元素创建了 ViewController,我想设置委托 [mapView setDelegate:self]
首先我在方法 initWithNibName:bundle: like: 中完成了它:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[[self map] setDelegate:self]];
UITabBarItem *item = [[UITabBarItem alloc] init];
[item setTitle:@"Map"];
[self setTabBarItem:item];
}
return self;
}
在这种情况下,MKMapView 没有向我发送任何消息,但是当我将设置委托消息设置为 viewDidLoad 方法时,它工作正常。
有人能解释一下为什么setting delegate message 在initWithNibName:bundle 中时它不起作用吗?
【问题讨论】:
标签: ios objective-c delegates mkmapview viewcontroller