模态视图:一个窗口或页面,当它出现时,整个窗口只能对它进行操作。例如登陆是出现的点注册出现的窗口。
主要方法:
呈现模态视图:presentViewController: animated: completion: ^
关闭模态视图:dismissViewControllerAnimated: completion:^
需要在stroyboard中添加一个viewController,并添加一个modalView类,设置号它的控制类和ID。
相关代码如下:
打开(MainViewController 中方法)
- (IBAction)go:(id)sender {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *modalViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"ModalView"];
[self presentViewController: modalViewController animated:YES completion:^{
}];
}
关闭(ModalViewController 中方法)
- (IBAction)back:(id)sender {
[self dismissViewControllerAnimated:YES completion:^{
}];
}