1#pragma mark-Gets the viewcontroller of the current screen display2-(Uiviewcontroller *) GETCURRENTVC3{4 Uiviewcontroller *result =Nil56 UIWindow * window =[[UIApplication sharedapplication] Keywindow];7if (window.windowlevel! =Uiwindowlevelnormal)8{9 Nsarray *windows =[[UIApplication sharedapplication] windows];10For (UIWindow * TmpwinInchWindows11{12if (Tmpwin.windowlevel = =Uiwindowlevelnormal)13{+ window =Tmpwin;15Break;16}17}18}19UIView *frontview = [[Window subviews] Objectatindex:021 id nextresponder = [ Frontview Nextresponder]; 22 23 if ([ Nextresponder iskindofclass:[uiviewcontroller class24 result = Nextresponder;else26 result = Window.rootviewcontroller; 27 28 return result; 29}
if you want to push and pop, you need to cast the return value of the calling method to the Uinavigationcontroller type
1 Uinavigationcontroller *nc = (Uinavigationcontroller *) [self GETCURRENTVC]; 2 [NC Popviewcontrolleranimated:yes];
UI base Gets the Viewcontroller of the current screen display