我想給用戶發送到另一個控制器,當他們點擊一個UIAlertView中的「確定」按鈕,但我發現了以下錯誤:轉發UIAlertView中點擊另一個cotroller
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可以正常工作。有什麼想法,我失蹤了?
的錯誤是非常自我解釋。您正在嘗試爲鍵「classname」設置一個零值。我沒有看到你發佈的代碼中的任何地方,所以我不認爲錯誤在這裏。你是否設置了一個異常斷點來查看它是否確定了違規行? – rdelmar 2013-02-25 02:57:01
當你點擊確定按鈕時,你的應用程序崩潰了嗎? – akiniwa 2013-02-25 03:28:55
@rdelmar斷點除main之外不顯示任何有用的內容。 – Anthony 2013-02-25 03:30:19