- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
- (void)loadView;
- (void)viewWillUnload
- (void)viewDidUnload
- (void)viewDidLoad;
- (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
- (void)viewDidAppear:(BOOL)animated; // Called when the view has been fully transitioned onto the screen. Default does nothing
- (void)viewWillDisappear:(BOOL)animated;// Called when the view is dismissed, covered or otherwise hidden. Default does nothing
- (void)viewDidDisappear:(BOOL)animated; // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
等等吧,相信这其中的调用流程,也该知道了,今天我想总结的是在两个,UIViewController之间来回跳转的时候,他的生命周期是怎么样的,以及一些调用流程。
这里我使用的是UINavigationController 这是一个导航栏,可以方便地在多个控制器之间来回跳转。
这是第一个控制器,名字为FirstViewController
这是加载这个控制器的时候,方法的调用顺序,现在我们点击书籍,会跳转到下一个页面。
在第一个控制器中单击书籍的处理事件:
- (void) bnClicked_in:(id) sender{
NSLog(@"function %s line=%d",__FUNCTION__,__LINE__);
//会调用init方法
SecondViewController *second=[[SecondViewControlleralloc] init];
//把下一个页面推入栈顶,会调用loadView方法
[self.navigationControllerpushViewController:second animated:YES];
NSLog(@"pushViewController之后");
[second release];
NSLog(@"把创建的second给release掉");
}
从上面的截图中很容易看出