【问题标题】:UIPopoverController not presenting in iPad iOS 8UIPopoverController 未出现在 iPad iOS 8 中
【发布时间】:2014-11-06 11:26:27
【问题描述】:

我在 iOS 8 iPad 中使用UIPopoverControllerimagepicker。它在 iOS 7 中工作,但在 iOS 8 中不工作。不显示弹出框,并立即调用 popoverControllerDidDismissPopover。请提出解决方案.. 这里的代码正在使用:

UIPopoverController *popVC= [[UIPopoverController alloc] initWithContentViewController:pickerController];
_pop = popVC;
_pop.delegate = self;
[_pop presentPopoverFromRect:attachBtnFrame inView:_sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

谢谢..

【问题讨论】:

    标签: ios ipad ios8 uipopovercontroller


    【解决方案1】:

    终于找到了解决办法: 在主线程中显示 Popover,如下所示。

    if([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0)
    {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
          [_pop presentPopoverFromRect:attachBtnFrame inView:_sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
        });
    }
    

    【讨论】:

    • 如果您不想延迟,可以使用dispatch_async 而不是dispatch_after
    • 这对我不起作用。它还在 iOS 8.1.1 中为您工作吗??
    • @zezba9000 YES。8.1.1 不需要更改
    • 感谢您的解决方案...花了很多时间后,我以这种方式解决了。
    【解决方案2】:

    把这个方法放在你的appDelegate.m中

    +(BOOL)isIOS8
    
    {
         NSString* version=[[UIDevice currentDevice] systemVersion];
        if ([version integerValue]>=8.0)
         {
             return YES;
         }
         else
         {
             return NO;
         } 
    }
    

    现在,当您想使用 PopoverController 时,只需通过上述方法检查系统操作系统,如

    if([AppDelegate isIOS8])
    

    比使用这个方法

    if([AppDelegate isIOS8])
            {
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(),
                     ^{[self.popover presentPopoverFromRect:popoverRect
                                                  inView:self.view
                                permittedArrowDirections:UIPopoverArrowDirectionUp
                                                animated:YES];});
            }
            else
            {
                [self.popover presentPopoverFromRect:popoverRect
                                              inView:self.view
                            permittedArrowDirections:UIPopoverArrowDirectionAny
                                            animated:YES ];
            }
    

    这个方法非常适合我,它应该适合你......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-03
      • 1970-01-01
      • 2014-09-16
      • 1970-01-01
      • 2015-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多