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

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -