ios - swift - Popover is not displayed correctly in landscape mode -
popover takes complete screen when displayed in landscape mode, works correctly in portrait mode though. also, not disappear when click outside popover in landscape mode.
i connected popover through storyboard. inside popoverviewcontroller placed view contains buttons. code viewdidload() of popoverviewcontroller is:
override func viewdidload() { super.viewdidload() self.preferredcontentsize = popoverview.frame.size } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. }
portrait:
landscape:
you have add uipopoverpresentationcontrollerdelegate
to class this:
swift 3
import uikit class viewcontroller: uiviewcontroller, uipopoverpresentationcontrollerdelegate { ...
as second step, add following function:
func adaptivepresentationstyle(for controller: uipresentationcontroller, traitcollection: uitraitcollection) -> uimodalpresentationstyle { return uimodalpresentationstyle.none }
explanation: returning uimodalpresentationstyle none, original presentation style kept , popover not streched bottom of screen in landscape orientation.
Comments
Post a Comment