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
Post a Comment