如何从 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/