2011-03-29 79 views

回答

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..."); 
} 
+0

我可以得到一个示例代码吗? – ishhhh 2012-11-12 10:10:37

+0

我添加了一些示例代码。如果您有任何问题,请告诉我。 – FreeAsInBeer 2012-11-12 14:23:54

+0

@Downvoter为什么downvote? – FreeAsInBeer 2013-12-27 14:14:05

2

我一直觉得很奇怪,一个UIViewController知道它应该有多大的酥料饼通过它的“contentSizeForViewInPopover”属性,但指针不保留到UIPopoverController本身。我总是最后加入:

@property (nonatomic,assign) UIPopoverController* popover; 

我的UIViewController类,并设置,当创建popover。然后从该UIViewController中的任何东西,我可以这样做来解雇popover:

[popover dismissPopoverAnimated:YES]; 
相关问题