ios - self.window.rootViewController.presentedViewController returning nil -


self.window.rootviewcontroller.presentedviewcontroller

always returning nil though there viewcontroller available. not sure doing wrong.

below full code-

- (uiinterfaceorientationmask)application:(uiapplication *)application supportedinterfaceorientationsforwindow:(uiwindow *)window {  nslog(@"this loaded"); if ([self.window.rootviewcontroller.presentedviewcontroller iskindofclass:[secondviewcontroller class]]) {     secondviewcontroller *secondcontroller = (secondviewcontroller *) self.window.rootviewcontroller.presentedviewcontroller;      if (secondcontroller.ispresented)     {         return uiinterfaceorientationmasklandscape;     }     else return uiinterfaceorientationmaskportrait; } else return uiinterfaceorientationmaskportrait; } 

self.window.rootviewcontroller.presentedviewcontroller. think returns uinavigationcontroller type class. please check inside log or debug.

 uinavigationcontroller* navigationcontroller = (uinavigationcontroller*)self.window.rootviewcontroller.presentedviewcontroller;  nsarray *arrayvc =navigationcontroller.viewcontrollers;         (uiviewcontroller* viewcontroller in arrayvc) {                  //this if condition checks whether viewcontroller's class secondviewcontroller                  if ([viewcontroller iskindofclass:[secondviewcontroller class]] )                  {                     //do                 }            } 

Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -