1.1Segue 连线跳转
- 明确跳转源头:明确地知道跳转动作是由哪个控件触发的
- 不明确跳转源头:无法确定跳转动作是由哪个控件触发的,只是可以确定当前界面是要跳转到另外一个界面
1.2跳转到故事板中独立的控制器
1.3从故事板中跳转到xib创建的控制器中
1.4跳转到其他故事板
ViewController.m
#import "ViewController.h"
#import "xibViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//跳转到蓝色界面
//不明确跳转源头
[self performSegueWithIdentifier:@"gotoBVC" sender:nil];
}
- (IBAction)gotoOtherVc:(id)sender {
UIViewController *otherVC = [self.storyboard instantiateViewControllerWithIdentifier:@"otherVC"];
[self presentViewController:otherVC animated:YES completion:nil];
}
- (IBAction)gotoXibVc:(id)sender {
[self presentViewController:[[xibViewController alloc]initWithNibName:@"xibViewController" bundle:nil] animated:YES completion:nil];
}
- (IBAction)gotoOtherStoryBoard:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"other" bundle:nil];//bundle文件夹路径,bundle:nil默认为当前路径
//跳转其他故事板中 指定的 控制器中
UIViewController *vc =[storyboard instantiateViewControllerWithIdentifier:@"blueVC"];
//跳转到其他故事板中 初始的 控制器中
//UIViewController *vc = [storyboard instantiateInitialViewController];
[self presentViewController:vc animated:YES completion:nil];
}
BlueViewController.m
@implementation BlueViewController
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
网友评论