IOS学习之——Modal( 登陆,注册)

//************************************************************************************************************      -13  Modal (登陆,注册)1)默认效果: 新控制器从屏幕的最底部往上钻,直到盖住之前的控制器为止。
                (2)除了push 之外  还有一种控制器的切换方式, 那就是modal
                (3)任何控制器都能通过Modal的形式展示出来
                (4) 以modal 的形式展示控制器
                -(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void(^)(void))completion
                (5)关闭当初model 出来的控制器
                -(void) dismissViewControllerAnimated:(BOOL)flag completion:(void(^)(void)completion);



      操作步骤:(1)建项目  sb设置成适合所有iphone
              (2)拉一个navigation controller 到 sb 删除 rootViewController  设置箭头指向navigation controller
              (3)navigation controller  control指向 view controller  设置为 rootViewController   拉控件设置成一个登陆注册的页面
              (4)再拉一个navigation controller      在 view controller  中有一个注册的button按钮  control 指向 新建的navigation controller 设置为present modally

              (5) 在新的navigation controller 中的root view controller 中设置标题为 注册
              (6)在注册中设置一个item 为返回按钮  (只能通过代码的方式返回) 需要创建一个类 RegisterViewController   继承 UITableViewController
               (7) 在sb 中的注册控制器里设置3中 custom class 设置为 RegisterViewController
               (8) 把注册页面的返回按钮连线 RegisterViewController.m 文件中  @interface @end 之间 设置为action 名称为back
                //modal
                - (IBAction)back:(id)sender {


                    [self dismissViewControllerAnimated:YES completion:^{
                        NSLog(@"模态窗口消失完成");
                    }];
                }
                (9)view controller.m  中导入 #import "RegisterViewController.h"
                在 新navigationController ˙中的  Identity 中的 storyboard ID 设置 registerNavId
                -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

                    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                    id regVc =[storyboard instantiateViewControllerWithIdentifier:@"registerNavId"];
                    [self presentViewController:regVc animated:YES completion:^{NSLog(@"模式窗口展现完成");}];


                }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值