我想显示一个视图控制器作为UIPopoverPresentationController下面的按钮或在窗口的中心。但它始终显示为完整窗口模式弹出窗口。UIPopoverPresentationController显示全屏幕模式弹出总是
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MySecondViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"Pop"];
// present the controller
// on iPad, this will be a Popover
// on iPhone, this will be an action sheet
controller.modalPresentationStyle = UINavigationControllerOperationPop;
[self presentViewController:controller animated:YES completion:nil];
controller.preferredContentSize = CGSizeMake(280, 230);
// configure the Popover presentation controller
UIPopoverPresentationController *popController = [controller popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionUp;
popController.delegate = self;
// in case we don't have a bar button as reference
popController.sourceView = self.showPop;
popController.sourceRect = CGRectMake(384, -120, 280, 230);
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
我要去使用栏按钮......它让我tablewiew上全屏...我应该怎么办?@·哈桑·阿夫塔卜 –
@SurajSukale,它可能是太晚了你,但也许其他人可以从这个评论中受益。您应该将一个委托分配给controller.popoverPresentationController并在委托实现方法'adaptivePresentationStyle(for:UIPresentationController)'中,返回值为'UIModalPresentationStyleNone' – Lukas1