2011-05-18 52 views
0

嗨在我的應用程序中,我有一個按鈕,所以當您點擊它時,UIPopover會在其中添加聯繫人視圖。除了當你按下保存時,所有工作人員。它不會消失。從UIPopover關閉添加聯繫人視圖控制器

-(IBAction) addcontact 
{ 
    ABNewPersonViewController *contacts = [[ABNewPersonViewController alloc] init]; 
    // imagePicker.delegate = self; 
    // UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:contacts]; 
    UINavigationController *addContactNavController = [[UINavigationController alloc] initWithRootViewController:contacts]; 

    popover = [[UIPopoverController alloc] initWithContentViewController:addContactNavController]; 

    popover.popoverContentSize = CGSizeMake(320, 1000); 
    [popover presentPopoverFromRect:CGRectMake(935, 270, 175, 300) 
          inView:self.view 
      permittedArrowDirections:UIPopoverArrowDirectionRight 
          animated:YES]; 
    [popover retain]; 
    [addContactNavController release]; 
    [contacts release]; 
} 

回答

0

完成落實​​協議,並在你的方法上面指派的委託 -

contacts.newPersonViewDelegate = self; 

然後,您可以關閉該popover中的代表功能 -

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView 
     didCompleteWithNewPerson:(ABRecordRef)person { 
    [popOver dismissPopoverAnimated:YES]; 
} 

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { 
    [popOver release]; 
} 
0

井,

[自dismissModalViewControllerAnimated:YES]; respecively [popover dismissPopoverAnimated:YES];

應該這樣做嗎?

編輯:更具體:

....

popover = [[UIPopoverController alloc] initWithContentViewController:addContactNavController]; 
    addContactNavController.delegate = self; 
現在

對儲蓄,這樣做:

-(IBAction) saveStuff { 
     ... saving... 
     [delegate closePopup]; 
    } 

,並在你的文件, - (IBAction爲) addcontact you do:

-(void) closePopup { 
      [self dismissModalViewCotroller...]; 
    } 

有道理?

,是的,你應該委託,屬性格式添加到您的控制器,如果沒有

+0

我該把它放在哪裏? – BDGapps 2011-05-19 04:33:31

+0

保存聯繫人 – thedanielhanke 2011-05-19 04:35:57

+0

它仍然無法正常工作 – BDGapps 2011-05-19 04:53:18