开发者

Moving Between Multiple XIB Files

开发者 https://www.devze.com 2022-12-20 14:00 出处:网络
It\'s my understanding that in order to move between xib files one usuall开发者_JAVA百科y uses either a Navigation Controller, Tab Controller, or Flipside Controller or combination of them.

It's my understanding that in order to move between xib files one usuall开发者_JAVA百科y uses either a Navigation Controller, Tab Controller, or Flipside Controller or combination of them.

But my question is- can I write my own custom controller, and use Core Animation to move between Views or are these default controllers (navigation/tab/flipside) the only options to transition between xib files?


Yes you can. One way to do this is to have a root level view controller, call it RootViewController, that knows about the child view controllers. Then it's just a matter of setting up and running an animation block that removes one childViewController's view from RootViewController and adds another childViewController's view to RootViewController. The animation block would probably be triggered from some action method.


You can use a rootController, in that situation you're gonna use

/* RootController */

  • (void) showSomething:(id)_example { self.view = somethingController.view; //Setting your view somethingController.example = _example; //You can even set property between your views }

/* UIViewController+RootControllerAccess */

// .H

import "RootController.h"

@interface UIViewController (RootControllerAccess) -(RootController *) rootController; @end

// .M

import "UIViewController+RootControllerAccess.h"

@implementation UIViewController (RootControllerAccess)

-(RootController*) fadeController{ return (RootController *)self.view.window.rootViewController; }

@end

/* Here you go, you're set to call any views any where

by doing this you can use anywhere showSomething : [self.rootController showSomething:nil];

0

精彩评论

暂无评论...
验证码 换一张
取 消