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:

enter image description here

landscape:

enter image description here

you have add uipopoverpresentationcontrollerdelegateto 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

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -