AP102 2016/5/6
先在FirstViewController.h裡面呼叫
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
- (IBAction)pressNext:(UIButton *)sender {
// SecondViewController * vc =[self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
//Prepare the next page
SecondViewController * vc =(SecondViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
//Show the next page,
//animated means show animation YES or NO?
//completion:nil means dont's do anything.
[self presentViewController:vc animated:YES completion:nil];
}
@end
然後再到去清除viewcontroller
// SecondViewController.m
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (IBAction)goback:(UIButton *)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
// FirstViewController.m
#import "FirstViewController.h"
#import "SecondViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
-(void) viewDidLoad{
[super viewDidLoad];
NSLog(@"第一個viewcontroller 正經歷 viewDidLoad 階段");
}
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"第一個viewcontroller 正經歷 viewWillAppear 階段");
}
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"第一個viewcontroller 正經歷 viewDidAppear 階段");
}
-(void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSLog(@"第一個viewcontroller 正經歷 viewWillDisappear 階段");
}
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
NSLog(@"第一個viewcontroller 正經歷 viewDidDisappear 階段");
}
- (IBAction)pressNext:(UIButton *)sender {
// SecondViewController * vc =[self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
//Prepare the next page
SecondViewController * vc =(SecondViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
//Show the next page,
//animated means show animation YES or NO?
//completion:nil means dont's do anything.
[self presentViewController:vc animated:YES completion:nil];
}
@end
Comments
Post a Comment