当用户单击 UIAlertView 上的“确定”按钮时,我试图将用户发送到另一个控制器,但出现以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: classname)'
我的 UIAertView 在这样的 if 语句中:
if([placemarks count] > 0)
{
CLPlacemark *foundPlacemark = [placemarks objectAtIndex:0];
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Location set"
message:[NSString stringWithFormat:@"Your location, was set to %@", foundPlacemark.country]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}
我正在检查单击的按钮:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
MasterViewController *controller=[[MasterViewController alloc]initWithNibName:@"MasterViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
}
}
我确实有委托集:
@interface LocationViewController : UIViewController <CLLocationManagerDelegate, UIAlertViewDelegate>
UIAlertView 可以自己正常工作。对我所缺少的有什么想法吗?