![](/img/trans.png)
[英]Dismissing a UIPopoverController from within its contentViewController?
[英]dismiss UIPopOverController from contentViewController
如何從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];
我認為保持引用也是一種方法,但我不知道保留它是否是一個好主意,因為當您需要釋放彈出控件時,由於會有額外的保留,它不會取消分配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.