我正在尝试为 iPad 和 iPhone 实现 Popover。在 iOS 9 之前,iPad 和 iPhone 有不同的 ViewController。使用 iOS9 应该有可能使用普通的 ViewController 和不同的 PresentationStyles 来做到这一点?(部署目标是 iOS 9.0)对吗?
根据这篇文章:
来自 Daniel Galasko 的 Stackoverflow 答案
我试图在目标 c 中实现这个答案。
_mediaTypePopoverVC = [[MediaTypePopoverVC alloc] initWithProductId:PRODUCT_ID_NONE_PARENT];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_mediaTypePopoverVC];
_popoverVC = [[UIViewController alloc] init];
_popoverVC.modalPresentationStyle = UIModalPresentationPopover;
_popoverVC.preferredContentSize = CGSizeMake(650.0, 364.0);
_popoverVC.popoverPresentationController.delegate = self;
[navigationController setViewControllers:@[_popoverVC]];
_mediaTypePopoverVC.title = POPOVER_TITLE(mediaType.name_en, (int) [mediaList count]);
_mediaTypePopoverVC.isCommonMediaList = YES;
[Logic sharedInstance].currentPopoverController = _popoverVC;
[self presentViewController:_popoverVC animated:true completion:nil];
UIPopoverPresentationController *popover = _popoverVC.popoverPresentationController;
if(nil != popover){
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
popover.sourceView = baseButton;
popover.sourceRect = baseButton.bounds;
}
崩溃将出现在这一行:
[self presentViewController:_popoverVC animated:true completion:nil];
我的日志只会给我这个:
Signal: SIGABRT (signal SIGABRT)