我在另一個視圖中有一個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