iOS在iphone设备上使用UIPopoverPresentationController在横屏状态显示问题解决办法
问题描述
在项目中使用UIPopoverPresentationController,项目中有横竖屏切换的需求,在竖屏状态下,显示正常,但是切换到横屏状态下,显示错误,在屏幕中央由下弹起。经过一番研究找到了解决办法。
解决方案
//只实现这个代理的话,会有横屏显示不正确的问题。
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}
//实现下面这个代理方法后,横屏状态下显示正常。
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
return UIModalPresentationNone;
}