UIKIT_EXTERN NSString *const UIViewControllerHierarchyInconsistencyException NS_AVAILABLE_IOS(5_0);
@interface UIViewController (UIContainerViewControllerProtectedMethods)
@property(nonatomic,readonly) NSArray *childViewControllers NS_AVAILABLE_IOS(5_0);//所以子视图控制器
- (void)addChildViewController:(UIViewController *)childController NS_AVAILABLE_IOS(5_0);//添加子视图控制器
- (void) removeFromParentViewController NS_AVAILABLE_IOS(5_0);//移除子视图控制器
//切换视图控制器(有很多效果)
- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(5_0);
- (void)viewDidLoad{
[super viewDidLoad];
onevc = [oneViewController new];
[self addChildViewController:onevc];
twovc = [twoViewController new];
[self addChildViewController:twovc];
[self.view addSubview:onevc.view];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self transitionFromViewController:onevc toViewController:twovc duration:1 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
} completion:^(BOOL finished) {
}];
}
//只在切换视图控制器的时候触发出发子视图控制器的 viewWillAppear (viewWillDisappear)(最好每个childVC都加上)
- (void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
- (void)endAppearanceTransition __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
[onevc beginAppearanceTransition:YES animated:YES];
[onevc endAppearanceTransition];
[twovc beginAppearanceTransition:YES animated:YES];
[twovc endAppearanceTransition];
//不使用自己的statusBar设置,而使用childVC的,一般需要从rootVC开始重写该方法。
- (UIViewController *)childViewControllerForStatusBarStyle NS_AVAILABLE_IOS(7_0);
- (UIViewController *)childViewControllerForStatusBarHidden NS_AVAILABLE_IOS(7_0);