问题
I am using UIPopoverController
in iOS 8 iPad for imagepicker
.Its working in iOS 7 but not in iOS 8.The popover is not displayed and popoverControllerDidDismissPopover
is called immediately.Please suggest a solution..
Here the code am using:
UIPopoverController *popVC= [[UIPopoverController alloc] initWithContentViewController:pickerController];
_pop = popVC;
_pop.delegate = self;
[_pop presentPopoverFromRect:attachBtnFrame inView:_sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
Thanks..
回答1:
Finally found the solution: Present the Popover in main thread as below.
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];
});
}
回答2:
Put this Method in your appDelegate.m
+(BOOL)isIOS8
{
NSString* version=[[UIDevice currentDevice] systemVersion];
if ([version integerValue]>=8.0)
{
return YES;
}
else
{
return NO;
}
}
now, when you want to use PopoverController just Check system OS by above method like
if([AppDelegate isIOS8])
than use this Method
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 ];
}
this Method works for me very well and it should work for you...
来源:https://stackoverflow.com/questions/25805643/uipopovercontroller-not-presenting-in-ipad-ios-8