从 contentViewController 中消除 UIPopOverController

发布于 2024-11-08 01:57:28 字数 967 浏览 7 评论 0原文

如何从 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];
}

How can you dismiss a popover from the contentViewController, so in the example code I have below I would like to dismiss the UIPopOver from the ProfileViewController code. How do I do this? Another post similar to this suggested to use NSNotification, but how do use it?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

末が日狂欢 2024-11-15 01:57:28

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

profile.popOver = profilePop;

然后在您想要忽略的区域:

[self.popover dismissPopoverAnimated:YES];

I would keep a reference to the popover in your profile class.

profile.popOver = profilePop;

then in the area you'de like to dismiss:

[self.popover dismissPopoverAnimated:YES];
双马尾 2024-11-15 01:57:28

我认为保留引用也是一种可行的方法,但我不知道保留它是否是一个好主意,因为当您需要释放弹出窗口控制器时,它不会释放,因为有一个额外的保留。

I think keeping a reference is the way to go too, but I don't know if its a good idea to retain it, because when you need to release the popover controller it won't dealloc because there is an extra retain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文