swift - Landscape orientation View Controller App Delegate -


i'm trying put view controller in landscape mode , other ones in portrait mode.

first of all, i've tried invalidate rotation of each view controller except 1 want (with shouldautorotate false, portrait, ...), navigation controller have, overlaps nav bar status bar, , couldn't solve it. after that, i've tried clean i've done , enable or disable orientation appdelegate.

so here's code found , tried:

    func application(application: uiapplication, supportedinterfaceorientationsforwindow window: uiwindow?) -> int {          if self.window?.rootviewcontroller?.presentedviewcontroller secondviewcontroller {              let secondcontroller = self.window!.rootviewcontroller!.presentedviewcontroller as! secondviewcontroller              if secondcontroller.ispresented {                 return int(uiinterfaceorientationmask.all.rawvalue);             } else {                 return int(uiinterfaceorientationmask.portrait.rawvalue);             }         } else {             return int(uiinterfaceorientationmask.portrait.rawvalue);         }      } 

but code never goes in first if (even if view controller secondviewcontroller).

so idea of how can check if i'm in specific vc can specify orientation?

thanks in advance!

checkout recursive method getting current viewcontroller

func getcurrentviewcontroller(viewcontroller:uiviewcontroller?)-> uiviewcontroller?{      if let tabbarcontroller = viewcontroller as? uitabbarcontroller{          return getcurrentviewcontroller(tabbarcontroller.selectedviewcontroller)     }      if let navigationcontroller = viewcontroller as? uinavigationcontroller{         return getcurrentviewcontroller(navigationcontroller.visibleviewcontroller)     }      if let viewcontroller = viewcontroller?.presentedviewcontroller {          return getcurrentviewcontroller(viewcontroller)      }else{          return viewcontroller     } } 

and use on supported orientation method follow

func application(application: uiapplication, supportedinterfaceorientationsforwindow window: uiwindow?) -> int {      if let currentvc = getcurrentviewcontroller(self.window?.rootviewcontroller) as? secondviewcontroller{              return int(uiinterfaceorientationmask.all.rawvalue)      }     return int(uiinterfaceorientationmask.portrait.rawvalue) } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -