ios - Views not responding when forcing wrong orientation -


i having issue controls not responding on part of view/window. in case bottom part.

what doing presenting new window has portrait oriented root view controller. seems work fine if application supports portrait orientation. when application landscape-only bottom part of window not responsive.

(before start commenting should lock view controller orientation , allow application orientations let me tell framework , not have access application orientations. , yes, requirement show in portrait)

so naturally tried quick trick overriding window hit test result surprisingly correct. call supper return correct view, in example below return button pressed target method not trigger. there must else breaking pipeline.

example controller (you can copy , call static method showoverlay):

class overlayviewcontroller: uiviewcontroller {      class mywindow: uiwindow {         override func hittest(point: cgpoint, withevent event: uievent?) -> uiview? {             let toreturn: uiview? = super.hittest(point, withevent: event)             print(toreturn)             return toreturn;         }     }      var mywindow: uiwindow?      internal static func showoverlay() {         let window = mywindow(frame: fullscreenframe())         let controller = overlayviewcontroller()         window.rootviewcontroller = controller         window.windowlevel = uiwindowlevelstatusbar         window.makekeyandvisible()         window.backgroundcolor = uicolor.graycolor()         controller.mywindow = window          var y = 10.0         while y<2000.0 {             let view = controller.view             let btn = uibutton(frame: cgrect(x: 10.0, y: y, width: 120.0, height: 10.0))             view.addsubview(btn)             btn.addtarget(controller, action: "close:", forcontrolevents: .touchupinside)             btn.backgroundcolor = uicolor(white: cgfloat(y/2000.0), alpha: 1.0)              y += 10.0         }       }      func close(button: uibutton) {         print("did press \(button.frame.origin.y)")     }      internal static func fullscreenframe() -> cgrect {         return cgrect(x: 0.0,             y: 0.0,             width: (uiinterfaceorientationisportrait(uiapplication.sharedapplication().statusbarorientation) ? uiscreen.mainscreen().bounds.size.width : uiscreen.mainscreen().bounds.size.height),             height: (uiinterfaceorientationisportrait(uiapplication.sharedapplication().statusbarorientation) ? uiscreen.mainscreen().bounds.size.height : uiscreen.mainscreen().bounds.size.width))     }      override func supportedinterfaceorientations() -> uiinterfaceorientationmask {         return uiinterfaceorientationmask.portrait     }     override func preferredinterfaceorientationforpresentation() -> uiinterfaceorientation {         return uiinterfaceorientation.portrait     }      override func shouldautorotate() -> bool {         return false     }  } 

again reproduce issue need disable portrait support in plist.

when press of buttons log button hittest method. top buttons call target method close.

the workaround can think of support of orientations , rotate view manually applying transform. prefer keep window system if possible because pain cover , keep testing orientations, handling animations , forth...

thank help.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -