View is not able to uiviewcontroller Push,pop and other operations, if the jump operation, generally with agents, blocks, notifications and other implementation, how to achieve in Viewcontroller subview to achieve jump operation, In fact, just get the view where the Viewcontroller can be.
Get View location Uiviewcontroller
Uiview+uiviewcontroller.h
#import <UIKit/UIKit.h> @interface UIView (Uiviewcontroller)-(Uiviewcontroller *) Viewcontroller; @end
Uiview+uiviewcontroller.m
#import "Uiview+uiviewcontroller.h" @implementation UIView (Uiviewcontroller)-(Uiviewcontroller *) Viewcontroller { //Through the responder chain, get view controller Uiresponder *next = Self.nextresponder; do { //Determine if the responder object is a view controller type if ([Next Iskindofclass:[uiviewcontroller class]]) { return (Uiviewcontroller *) Next; } Next = Next.nextresponder; } while (next! = nil); return nil;} @end
Or
-(Uiviewcontroller *) Viewcontroller { //Traverse responder chain. Return first found view controller, which would be is the view ' s view Controller. Uiresponder *responder = self; while ((responder = [responder Nextresponder])) if ([responder Iskindofclass: [Uiviewcontroller class]]) Return (Uiviewcontroller *) responder; return nil;}
-(uiviewcontroller*) Viewcontroller {for (uiview* next = [self superview]; next; next = Next.superview) { Uirespo nder* Nextresponder = [next Nextresponder]; if ([Nextresponder Iskindofclass:[uiviewcontroller class]] { return (uiviewcontroller*) nextresponder; } } return nil;}
Use:
Import #import "Uiview+uiviewcontroller.h" in Subview
-(void) viewdidselect{ webviewcontroller *VC = [[Webviewcontroller alloc] init]; Vc.weburl [email protected] "http://www.baidu.com"; [Self.viewController.navigationController PUSHVIEWCONTROLLER:VC Animated:yes];}
Implement Uiviewcontroller jumps in view