As titled, in iOS8, [UIPopoverController presentPopoverFromRect] does not work for [UIApplication sharedApplication].keyWindow any more. (It does work in iOS7)
I verifi
Try the solution found at this link: http://github.com/werner77/WEPopover
1st, let's do this code:
if ([viewController respondsToSelector:@selector(setPreferredContentSize:)]) {
viewController.preferredContentSize = CGSizeMake(200, 300.0f);
} else {
viewController.contentSizeForViewInPopover = CGSizeMake(200.0f, 300.0f);
}
self.popoverController = [[popoverClass alloc] initWithContentViewController:viewController];
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
}
self.popoverController.delegate = self;
[self.popoverController presentPopoverFromRect:[sender bounds]
inView:sender
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
I hope this helps. It was tested and works for iOS6-iOS8.
PS. Don't forget to check viewDidLoad
, and give thanks to the WEPopover Library.