2011-06-28 42 views
4

我有一個UIPopover,它有一個navigationController堆棧。從該堆棧的第二個視圖中,我想在彈出窗口中以模態方式顯示ABPeoplePickerNavigationController。我有這個工作,但是當我解僱modalViewController時,UIPoover的原始導航控制器從彈窗中丟失。有沒有辦法使這個工作正常?下面的代碼:在UIPopover中顯示ABPeoplePickerNavigationController




    (IBAction)showPicker:(id)sender { 
     ABPeoplePickerNavigationController *picker = 
      [[ABPeoplePickerNavigationController alloc] init]; 
     picker.peoplePickerDelegate = self; 

     picker.modalPresentationStyle = UIModalPresentationCurrentContext; 
     picker.modalInPopover = YES; 
     [self presentModalViewController:picker animated:YES]; 
     // self is the 2nd viewController in the original navigation stack 
     [picker release]; 
    } 

    (void)peoplePickerNavigationControllerDidCancel: 
     (ABPeoplePickerNavigationController *)peoplePicker { 
      [self dismissModalViewControllerAnimated:YES]; 
    } 

+0

我與contentSizeForViewInPopover,modalTransitionStyle和modalPresentationStyle的各種組合周圍打了幾個小時,在得到這個工作絕對沒有運氣 - 在選擇器總是以覆蓋彈出窗口的新視圖打開。有沒有其他的魔法可以使它不起作用?如果是這樣,你可以添加它作爲評論或編輯上述解決方案? –

+0

嗯,我終於搞定了。試圖呈現選擇器的視圖的popoverContentSize太小。我問picker它的contentSizeForViewInPopover屬性,它說全高320寬,我設置彈出popoverContentSize這個數字,它的工作。 –

回答

0

問題解決如下:

[self.navigationController presentModalViewController:picker animated:YES]; 
相關問題