iOS学习笔记-050.Modal模态
来源:互联网 发布:julius it 编辑:程序博客网 时间:2024/06/10 02:00
- Modal模态
- 一Modal介绍
- 二Modal操作
- 三代码
- WMOneViewControllerm
- WMTwoViewControllerm
- WMThreeViewControllerm
- 四图示
Modal模态
一、Modal介绍
除了push之外,还有另外一种控制器的切换方式,那就是Modal
任何控制器都能通过Modal的形式展示出来
Modal的默认效果:新控制器从屏幕的最底部往上钻,直到盖住之前的控制器为止
二、Modal操作
以Modal的形式展示控制器- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion关闭当初Modal出来的控制器- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;
三、代码
WMOneViewController.m
//// WMOneViewController.m// 03_UIView40_Modal//// Created by 杞文明 on 2016/04/10 11:54:06 星期日// Copyright © 2016年 杞文明. All rights reserved.//#import "WMOneViewController.h"#import "WMTwoViewController.h"@interface WMOneViewController ()@end@implementation WMOneViewController- (void)viewDidLoad { [super viewDidLoad];}- (IBAction)jump2Two:(id)sender { //1.创建控制器 WMTwoViewController * vc = [[WMTwoViewController alloc]init]; //2.创建导航控制器 UINavigationController *nvc = [[UINavigationController alloc]initWithRootViewController:vc]; //3.模态方式打开控制器 [self presentViewController:nvc animated:YES completion:^{ NSLog(@"完全打开 第二个了"); }];}@end
WMTwoViewController.m
//// WMTwoViewController.m// 03_UIView40_Modal//// Created by 杞文明 on 2016/04/10 11:53:50 星期日// Copyright © 2016年 杞文明. All rights reserved.//#import "WMTwoViewController.h"#import "WMThreeViewController.h"@interface WMTwoViewController ()@end@implementation WMTwoViewController- (void)viewDidLoad { [super viewDidLoad]; //返回按钮 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(closeTwo)];}/** *跳到第三个界面 */- (IBAction)jump2Three:(id)sender { //1.创建控制器 WMThreeViewController *vc = [[WMThreeViewController alloc]init]; //2.模态方式打开 [self presentViewController:vc animated:YES completion:^{ NSLog(@"完全打开 第三个了"); }];}-(void)closeTwo{ // 如果一个控制器是以模态的形式展现出来的, 可以调用该控制器以及该控制器的子控制器让让控制器消失// [self dismissViewControllerAnimated:YES completion:^{// NSLog(@"完全打开 第二个了");// }]; [self.navigationController dismissViewControllerAnimated:YES completion:^{ NSLog(@"完全打开 第二个了"); }];}@end
WMThreeViewController.m
//// WMThreeViewController.m// 03_UIView40_Modal//// Created by 杞文明 on 2016/04/10 11:53:59 星期日// Copyright © 2016年 杞文明. All rights reserved.//#import "WMThreeViewController.h"@interface WMThreeViewController ()@end@implementation WMThreeViewController- (void)viewDidLoad { [super viewDidLoad];}//关闭- (IBAction)myClose:(id)sender { [self dismissViewControllerAnimated:YES completion:^{ NSLog(@"已经关闭 第三个了"); }];}@end
四、图示
0 0
- iOS学习笔记-050.Modal模态
- ios 控制器 modal 学习
- [iOS学习]iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- 【IOS 开发学习总结-OC-55】故事板中 segue 的 push、modal、popover、replace、custom 学习笔记
- iOS学习笔记—— Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- iOS学习笔记—— Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- IOS学习之——Modal( 登陆,注册)
- ReactNative学习笔记--基于Modal的多步弹窗的封装
- ReactNative学习笔记--基于Modal的多步弹窗的封装
- ReactNative学习笔记--基于Modal的多步弹窗的封装
- iOS VC Modal Styles
- IOS modal介绍
- iOS自定义Modal
- iOS中modal跳转总结
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发笔记2—— UI篇—Modal简单介绍
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- java的异常处理
- Linux中最危险的是个命令(很有趣呦~)(链接:http://os.51cto.com/art/201408/448756.htm)
- IOS中多个网络请求问题
- 多线程的实现方法
- (1)创建解决方案项目
- iOS学习笔记-050.Modal模态
- mybatis高级查询-一对一查询
- neuraltalk2将eval.lua改成一个服务 不断的增量分析图像
- 算法课第2周第2题——241. Different Ways to Add Parentheses
- intellij live Templates 设置
- 【数组】Leetcode编程题解:289. Game of Life Add to List
- 高级查询
- 算法基础之冒泡排序
- android逆向工具