objective c - UIAlertController:supportedInterfaceOrientations was invoked recursively -
when 2 alert present 1 one, means 1 alert present , on them alert presenting , app crashing. have used uialertcontroller
display alert. app crashing in ios 9 device.
please me @ point.
this bug in ios 9 failed retrieve supportedinterfaceorientations
uialertcontroller
. , seems dropped infinite recursion loop in looking supportedinterfaceorientations
uialertcontroller
(e.g., tracks uialertcontroler
-> uiviewcontroller
-> uinavigationcontroller
-> uitabbarcontroller
-> uialertcontroller
-> ...), while call uialertcontroller:supportedinterfaceorientations
not implemented/overridden in source code.
in solution, added following piece of code:
extension uialertcontroller { public override func supportedinterfaceorientations() -> uiinterfaceorientationmask { return uiinterfaceorientationmask.portrait } public override func shouldautorotate() -> bool { return false } }
then uialertcontroller
directly return supported orientation value without infinite loop. hope helps.
edit: swift 3.0.1
extension uialertcontroller { open override var supportedinterfaceorientations: uiinterfaceorientationmask { return uiinterfaceorientationmask.portrait } open override var shouldautorotate: bool { return false } }
Comments
Post a Comment