从contentViewController中解除UIPopOverController

时间:2011-05-17 22:03:31

标签: iphone objective-c uipopovercontroller

如何从contentViewController中解除弹出窗口,因此在下面的示例代码中,我想从ProfileViewController代码中解除UIPopOver。我该怎么做呢?另一篇类似于此的帖子建议使用NSNotification,但如何使用呢?

- (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];
}

2 个答案:

答案 0 :(得分:4)

我会在你的个人资料类中保留对popover的引用。

profile.popOver = profilePop;

然后在你想要解雇的地区:

[self.popover dismissPopoverAnimated:YES];

答案 1 :(得分:0)

我认为保留引用也是一种方法,但我不知道保留它是否是一个好主意,因为当你需要释放popover控制器时它不会dealloc因为有一个额外的保留