注解子类自定义initWithCooperative
我对 MKAnnotation 进行了子类化,以便我可以将对象分配给每个注释,这样当单击 rightCalloutAccessoryView 时,我可以推送导航控制器并将对象传递给它,并在另一个视图中显示对象数据。
除了一件事之外,这一切都工作得很好,我已经像这样扩展了 initWithCooperative:
-(id)initWithCoordinate:(CLLocationCoordinate2D)coord andObject:(NSManagedObject *)object {
[self setPlace:object];
coordinate = coord;
title = [place valueForKey:@"name"];
subtitle = [place valueForKey:@"address"];
return self;
}
虽然一切都工作得很好,但我收到了警告:
NO '-initWithCoordinate:andObject:' method found
这意味着我在某个地方做错了,添加的正确方法是什么初始化与坐标?
I've subclassed MKAnnotation so that i can assign objects to each annotation, this is so that when the rightCalloutAccessoryView is clicked i can push a navigation controller with the object passed to it and display the objects data in another view.
This all works great apart from one thing, i've extended upon initWithCoordinate like so:
-(id)initWithCoordinate:(CLLocationCoordinate2D)coord andObject:(NSManagedObject *)object {
[self setPlace:object];
coordinate = coord;
title = [place valueForKey:@"name"];
subtitle = [place valueForKey:@"address"];
return self;
}
Although everything is working great i'm recieving the warning:
NO '-initWithCoordinate:andObject:' method found
Which means i'm doing something wrong somewhere, what is the correct way to go about adding upon initWithCoorinate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将原型
-(id)initWithCooperative:(CLLocationCooperative2D)coord andObject:(NSManagedObject *)object
放入 .h 文件中。Put the prototype
-(id)initWithCoordinate:(CLLocationCoordinate2D)coord andObject:(NSManagedObject *)object
in .h file.