【发布时间】:2016-08-05 18:22:13
【问题描述】:
所以我试图通过按下按钮在应用程序中打开视图,但显示以下错误:
'NSInvalidArgumentException', reason: '-[UINavigationBar copyWithZone:]: unrecognized selector sent to instance 0x1e56aa10'
按钮按下的动作是:
-(IBAction)launchDirections:(id)sender
{
@autoreleasepool {
if([CLLocationManager locationServicesEnabled]){
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied
|| [CLLocationManager authorizationStatus]==kCLAuthorizationStatusNotDetermined
|| [CLLocationManager authorizationStatus]==kCLAuthorizationStatusRestricted ){
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}else{
NSLog(@"Location Services Enabled");
ontracDirectionsMapViewController *directions = [[ontracDirectionsMapViewController alloc] init];
directions.start = userLocation;
directions.end =selectedPointLocation;
//[self presentViewController:directions animated:NO completion:nil];
//[self.navigationController pushViewController:directions animated:YES];
[ self presentViewController : directions animated : YES completion : ^ {
NSLog ( @ "hello" );
}];
}
}
}
}
此外,我已经尝试了您可以看到已被注释掉的两行:
//[self presentViewController:directions animated:NO completion:nil];
//[self.navigationController pushViewController:directions animated:YES];
不幸的是,这些没有任何区别。我是 IOS 开发新手,不知道从哪里开始。
此外,应用程序中的其他地方还有一个名为 copyWithZone 的方法,但即使我完全删除它,我仍然会收到参考错误。
-(id)copyWithZone:(NSZone *)zone
{
ontracTableMasterViewController *copy = [[ontracTableMasterViewController alloc] init];
copy.cookieValue = self.cookieValue;
copy.dataObject = self.dataObject;
return copy;
}
【问题讨论】:
-
ontracDirectionsMapViewController在故事板上? -
@Lion 是的,我认为
-
有一个答案。这似乎是对的。这样做。
-
AFAIK:
copyWithZone是[复制](developer.apple.com/library/mac/documentation/Cocoa/Reference/…) 的协议方法,即您有一个类似于@property ( someOther attributes, copy)的属性...但您不能只说也就是说,您要复制的对象必须遵循/conform/adaptNSCopying协议,否则会给您这样的错误。参见this 以及
标签: ios objective-c xcode