I’m looking to present a UIPopoverController from a button on a UICollectionViewCell.
So far, everything is created ok, but the popover isn’t visible.
Is there a special way of doing this?
The code works if I display it from anything else other than a collection view cell.
The following code is in the UICollectionViewCell subclass.
if (_infoPopover == nil) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
GameInfoViewController *gameInfoVC = (GameInfoViewController *)[storyboard instantiateViewControllerWithIdentifier:@"GameInfoViewController_ID"];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:gameInfoVC];
_infoPopover = popover;
[gameInfoVC setGameNameString:_gameNameLabel.attributedText];
}
[_infoPopover presentPopoverFromRect:_infoButton.frame inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Thanks!
Perform PopOver from UIViewController, not in UICollectionViewCell. So, use delegate to control.
implement protocol
And the code for you: https://github.com/lequysang/TestPopOver