• iOS 页面跳转和返回,持续编写


    如果使用导航
    第一个按钮方法:
    [self.navigationController pushViewController:secondVC animated:YES];
    第二个按钮方法:
    [self.navigationController popViewControllerAnimated:YES];
    
    如果使用模态
    第一个按钮方法:
    [self presentViewController:secondVC animated:YES completion:nil];
    第二个按钮方法:
    [self dismissViewControllerAnimated:YES completion:nil]; 

    [self dismissViewControllerAnimated:YES completion:^{}];

    直接跳转到首页
    模态

    [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];
    导航栏
     [self.navigationController popToRootViewControllerAnimated:YES];
    在页面中重写返回按钮事件

    - (void)viewDidLoad {

        [super viewDidLoad];

      UIButton * back =[UIButton addBtnImage:@"back" AndFrame:CGRectMake(0, 0, 30, 30) WithTarget:self action:@selector(leftBtnClick)];

    self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithCustomView:back];
    }

    #pragma mark-->  返回点击事件

    
    

    -(void)leftBtnClick{

    NSLog(@"返回按钮点击事件");

    这里是返回三层前,1234,4->1

     int index = (int)[[self.navigationController viewControllers]indexOfObject:self];

        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:(index -3)] animated:YES];

    }

    //跳到上一层的上一层

    //    UIViewController *viewCtl = self.navigationController.viewControllers[1];

    
    

    //    [self.navigationController popToViewController:viewCtl animated:YES];



    https://blog.csdn.net/u011096206/article/details/50606778


    1.从视图A中navigation controller push到视图B,当视图B navigationcontroller pop回到视图A时,并不会调用A的viewDidLoad,但是会调用viewWillAppear,所以如果视图A有需要变更的内容应该在viewWillAppear中实现。

    
    

    2.当一个视图生成时是先调用viewDidLoad,再调用viewWillAppear的。

    
    

    3.如果视图刷新时,其中的内容没有改变,要考虑内容的数据源是否被变更了

  • 相关阅读:
    angular6 增加webpack配置 亲测可用
    Git 忽略提交 .gitignore
    pc 媒体查询
    angular vue通过node启动项目局域网内关闭防火墙无法访问的解决办法
    js判断isNumber(obj)
    hook
    javascript中this的四种用法
    JavaScript中闭包函数
    JavaScript(ES3)中的方法, 及bind apply call的使用
    ES6 箭头函数
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/8135655.html
Copyright © 2020-2023  润新知