我正在尝试为iPad和iPhone实现一个Popover。 在iOS 9之前,iPad和iPhone有不同的ViewController。 对于iOS9,应该有可能使用普通的ViewController和不同的PresentationStyles吗? (部署目标是iOS 9.0) 我是对的吗?
根据这篇文章:
Stackoverflow answer from Daniel Galasko
我试图在目标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)