我在另一个视图中有一个UIPopoverController
命名为popover
。我想知道的是,如果在当前弹出窗口视图中按下了UIButton
,我该如何解除弹出窗口?提前致谢。从另一个视图中关闭UIPopoverController
0
A
回答
1
您可以使用NSNotification来告诉其他视图忽略它的弹出视图。
用法示例:
// Add an observer that will respond to our notification.
[[NSNotificationCenter defaultCenter] addObserver:self // <- This is the object that will has the selector that we want to run (the same one we use in the next line).
selector:@selector(doSomething:) // <- This is the selector we want to run.
name:@"doSomethingNow" // <- This is notification name we will send to activate our observer's selector.
object:nil]; // Don't worry about this for now.
// Post the notification. This has the same name as our observer above, so our 'doSomething' selector should be run.
[[NSNotificationCenter defaultCenter] postNotificationName:@"doSomethingNow" object:nil];
// the function specified in the same class where we defined the addObserver
- (void)doSomething:(NSNotification *)pNotification {
NSLog(@"Received Notification...");
}
2
我一直觉得很奇怪,一个UIViewController知道它应该有多大的酥料饼通过它的“contentSizeForViewInPopover”属性,但指针不保留到UIPopoverController本身。我总是最后加入:
@property (nonatomic,assign) UIPopoverController* popover;
我的UIViewController类,并设置,当创建popover。然后从该UIViewController中的任何东西,我可以这样做来解雇popover:
[popover dismissPopoverAnimated:YES];
相关问题
- 1. 如何从另一个viewcontroller关闭UIPopoverController?
- 2. 关闭一个UIPopoverController
- 3. 从另一个视图中关闭模式(通过代理)
- 4. 如何使用BarButtonItem打开另一个时关闭UIPopoverController?
- 5. 关闭视图控制器到另一个视图swift 3
- 6. 关闭didSelectRowAtIndexPath上的UIPopoverController
- 7. 关闭视图,然后显示另一个?
- 8. 从另一个视图调用视图
- 9. 从另一个视图呈现视图
- 10. 从另一个视图更新视图
- 11. 从另一个子视图
- 12. 将视图从一个视图移动到另一个视图
- 13. 在WPF中从一个视图导航到另一个视图
- 14. 关闭一些视图
- 15. 从另一个FormClosed事件中关闭一个活动表单
- 16. 从另一个表格中关闭一个表单?
- 17. 在其contentViewController中关闭了UIPopoverController?
- 18. 如何从视图中关闭键盘?
- 19. 试图关闭一个模式并打开另一个,但都保持关闭
- 20. UIPopovercontroller中的多个视图导航
- 21. 关闭一个JFrame而不关闭另一个?
- 22. 当一个人正在关闭/关闭时从另一个窗体绘制另一个窗体
- 23. 关闭一个DIV打开另一个
- 24. 如何从Silverlight中的viewmodel从一个视图导航到另一个视图?
- 25. 将值从一个视图传递到另一个视图
- 26. 将参数从一个视图转移到另一个视图?
- 27. 从一个视图切换到另一个视图:Java
- 28. 如何从一个视图切换到另一个视图?
- 29. 从一个视图获取变量到另一个视图
- 30. Android片段 - 从一个视图移动到另一个视图?
我可以得到一个示例代码吗? – ishhhh 2012-11-12 10:10:37
我添加了一些示例代码。如果您有任何问题,请告诉我。 – FreeAsInBeer 2012-11-12 14:23:54
@Downvoter为什么downvote? – FreeAsInBeer 2013-12-27 14:14:05