我在iOS 8 iPad中使用UIPopoverController
imagepicker
。它在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];
谢谢..
答案 0 :(得分:22)
终于找到了解决方案: 在主线程中显示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];
});
}
答案 1 :(得分:5)
将此方法放入appDelegate.m
+(BOOL)isIOS8
{
NSString* version=[[UIDevice currentDevice] systemVersion];
if ([version integerValue]>=8.0)
{
return YES;
}
else
{
return NO;
}
}
现在,当您想要使用PopoverController时,只需通过上面的方法检查系统OS,如
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 ];
}
这个方法非常适合我,它应该适合你...