2011-05-17 56 views
2

如何解除contentViewController的彈出窗口,所以在下面的示例代碼中,我想從ProfileViewController代碼中解除UIPopOver。我該怎麼做呢?另一個類似於此的帖子建議使用NSNotification,但如何使用它?解僱來自contentViewController的UIPopOverController

- (void)profilePop:(UITapGestureRecognizer *)recognizer 
{ 
    ProfileViewController * profile = [[ProfileViewController alloc] init]; 
    CGPoint location = [recognizer locationInView:self.table]; 
    NSIndexPath* indexPath = [self.table indexPathForRowAtPoint:location]; 
    ConvoreCell* cell = (ConvoreCell *) [self.table cellForRowAtIndexPath:indexPath]; 
    profile.uid = [[[self.posts objectAtIndex:indexPath.row] creator] mid]; 
    UIPopoverController * profilePop = [[UIPopoverController alloc] initWithContentViewController:profile]; 
    [profilePop setPopoverContentSize:CGSizeMake(350, 180)]; 
    [profilePop presentPopoverFromRect:CGRectMake(0,0, cell.avatar.frame.size.width, cell.avatar.frame.size.height) inView:cell permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 
} 

回答

4

我會保留對您的個人資料類中的彈出窗口的引用。

profile.popOver = profilePop; 

然後在該地區you'de喜歡解僱:

[self.popover dismissPopoverAnimated:YES]; 
+0

這可能是要走的路。還有許多其他情況,您需要將其他消息從內容視圖控制器發送到第一個視圖控制器,因此這是一個很好的模式。 – CharlieMezak 2011-05-17 23:08:46

0

我想保持一提的是也去的方式,但我不知道它是個好主意,保留它,因爲當你需要釋放popover控制器時,它不會釋放,因爲有一個額外的保留。