gpt4 book ai didi

ios - 我如何观察 UIPopoverController 何时被解除?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:31:55 24 4
gpt4 key购买 nike

UISplitViewController 有委托(delegate)方法:

-(void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController

我希望从类似但不存在的委托(delegate)方法中获取功能:

-(void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willDismissViewController:(UIViewController *)aViewController

关于考虑 UISplitViewController/UIPopoverController/UIKit 的最佳方式的想法通常不符合 KVO,所以我可以'将观察者添加到 UIPopoverControllerisPopoverVisible 属性。

谢谢

回答:

//Sent when switching to portrait
- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc
{
...

self.popoverController = pc;
[self.popoverController setDelegate:self];
}

-(void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController
{
NSLog(@"SHOWING POPOVER");
}

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
NSLog(@"HIDING POPOVER");
}

最佳答案

想通了,除了 UISplitViewControllerDelegate 之外,还添加 UIPopoverController 委托(delegate):

//Sent when switching to portrait
- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc
{
...

self.popoverController = pc;
[self.popoverController setDelegate:self];
}

-(void)splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController
{
NSLog(@"SHOWING POPOVER");
}

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
NSLog(@"HIDING POPOVER");
}

关于ios - 我如何观察 UIPopoverController 何时被解除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12059834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com