iphone - 从 contentViewController 中消除 UIPopOverController

标签 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];
}

最佳答案

我会在您的个人资料类中保留对弹出窗口的引用。

profile.popOver = profilePop;

然后在您想要关闭的区域中:

[self.popover dismissPopoverAnimated:YES];

关于iphone - 从 contentViewController 中消除 UIPopOverController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6037701/

相关文章:

ios - 克服安全错误 : DOM Exception 18 in PouchDB on Mobile Chrome for iOS

ios - 难以理解 Obj-C MVC : exit and unwindSegue

ios - 可以检测我的框架是作为主应用程序还是扩展程序的一部分运行?

ios - UIPopoverController不断重新加载UIWebView

iphone - 从Safari在iOS6中显示 native 推文对话

iphone - 核心数据 : any way to fetch multiple entities?

iphone - iOS 上的圆形按钮

iphone - UIPopoverController、UIActionSheet 和模态视图 Controller 的保留/ Release模式?

ios - UIPopoverController presentPopoverFromBarButtonItem :. .. 偏心

iphone - Objective-C:我可以用代码“监视”一个变量,以便它更改的瞬间可以将其更改回来?