ViewController 跳转方法总结
- (IBAction)ClickBtn:(id)sender {}
- (IBAction)ClickBtn:(id)sender {//获取当前的StoryboardUIStoryboard*sb=[UIStoryboard storyboardWithName:@"Main" bundle:nil];//在Storyboard中获取vc1ViewController1*vc1=[sb instantiateViewControllerWithIdentifier:@"vc1"];//呈现出vc1[self presentViewController:vc1 animated:YES completion:^{}];}
- (IBAction)ClickBtn:(id)sender {//initWithNibName后+vc2文件名ViewController2*vc2=[[ViewController2 alloc]initWithNibName:@"ViewController2" bundle:nil];//呈现出vc2[self presentViewController:vc2 animated:YES completion:^{}];}
self.view.backgroundColor=[UIColor whiteColor];UIButton*btn=[UIButton buttonWithType:UIButtonTypeCustom];btn.frame=CGRectMake(100, 100, 100, 100);[btn setTitle:@"出去" forState: UIControlStateNormal];[btn addTarget:self action:@selector(Click:) forControlEvents:UIControlEventTouchUpInside];btn.backgroundColor=[UIColor blueColor];[self.view addSubview:btn];
- (IBAction)ClickBtn:(id)sender {ViewController3*vc3=[[ViewController3 alloc]init];//呈现出vc3[self presentViewController:vc3 animated:YES completion:^{}];}
[self dismissViewControllerAnimated:YES completion:^{NSLog(@"vc跳出");}];