无法从另一个类中解除UIPopover

时间:2013-06-29 15:41:34

标签: ios6 uipopovercontroller

我有一个iPad应用程序,在XCode 4.6.3,iOS 6.2,ARC和Storyboard中创建。

我在SubViewData.m中以编程方式创建了一个UIPopover。

@property (strong, nonatomic) UIPopoverController *popover;

    //  make rectangle to attach popover
    CGRect rectangle = CGRectMake( touchPoint.x, touchPoint.y, 110, 1);  //  0 height puts arrow on exact touch point

    //  get addressability to storyboard ViewController
    UIViewController *popoverMainView = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"menuView"];

    popover = [[UIPopoverController alloc] initWithContentViewController:popoverMainView];
                            [popover presentPopoverFromRect:rectangle inView:self
                            permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

我在点击popover中的UIButton时在另一个类(QuickAppointment.m)中设置通知。我收到通知并从CalendarViewController.m发出此代码:

SubViewData *svd = [[SubViewData alloc] init];
[svd.popover dismissPopoverAnimated:YES];

什么都没发生!我不明白为什么不......所以,我做错了什么?

1 个答案:

答案 0 :(得分:1)

查看您正在编写的代码:

SubViewData *svd = [[SubViewData alloc] init];

这会创建一个全新且不同的 SubViewData实例,而不是显示popover的实例。