从 contentViewController 中消除 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];
}
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会在您的个人资料类中保留对弹出窗口的引用。
然后在您想要忽略的区域:
I would keep a reference to the popover in your profile class.
then in the area you'de like to dismiss:
我认为保留引用也是一种可行的方法,但我不知道保留它是否是一个好主意,因为当您需要释放弹出窗口控制器时,它不会释放,因为有一个额外的保留。
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.