zoukankan      html  css  js  c++  java
  • 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.如果视图刷新时,其中的内容没有改变,要考虑内容的数据源是否被变更了

  • 相关阅读:
    第三章 集合与排序 3-2 对表进行分组
    第三章 集合与排序 3-1 对表进行聚合排序
    第二章 基础查询 2-3 逻辑运算符
    第二章 基础查询 2-2 算术运算符和比较运算符
    第二章 基础查询 2-1 SQL语句基础
    第一章 数据库和SQL
    subprocess模块
    hashlib模块
    re
    ConfigParser模块
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/8135655.html
Copyright © 2011-2022 走看看