我試圖在已經推入的視圖控制器上像下面一樣推送視圖控制器。然而,不知何故,當我試圖推動newPersonViewController
時,這個新控制器不會被推入堆棧。我不知道爲什麼Xcode抱怨我試圖添加一個不屬於層次結構的新控制器。我是否錯誤地提供了ABPeoplePickerViewController
?這是newPersonViewController
無法推入堆棧的原因嗎?從控制檯iOS如何在已經堆疊的ViewController上調用presentViewController
消息:
警告:試圖提出有關誰的觀點是不是在窗口層次!
的代碼:
- (void)addPerson
{
ABNewPersonViewController *newPersonVC = [[ABNewPersonViewController alloc] init];
newPersonVC.newPersonViewDelegate = self;
UINavigationController *uiNav = [[UINavigationController alloc] initWithRootViewController:newPersonVC];
[self presentViewController:uiNav animated:YES completion:nil];
}
- (void)showPeoplePicker
{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
[picker.topViewController setEditing:YES];
picker.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPerson)];
picker.topViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(peoplePickerCancel)];
}
的問題的根源是'的存在[自presentViewController:...]''中因爲addPerson' 'self'不是當前的視圖控制器。只要改變這是新的財產,你就完成了!對不起,用編輯來折磨你! – Rob