zoukankan      html  css  js  c++  java
  • pop回指定控制器

    //OC
    NSArray *array = [NSMutableArray new]; array = self.navigationController.viewControllers; //1、返回指定index的控制器 UIViewController *viewC = [array objectAtIndex:0]; [self.navigationController popToViewController:viewC animated:YES]; //2、 UIViewController *viewc = [UIViewController new]; for (viewc in array) { if ([viewc isKindOfClass:[指定控制器 class]]) { [self.navigationController popToViewController:viewcanimated:YES]; } }

    //3、

     [vcArr removeObject:strongSelf];

      [self.navigationController setViewControllers:vcArr animated:NO];

     

     2、Swift

    //返回指定界面
    let marr = NSMutableArray.init(array:(self.navigationController?.viewControllers)!)
    for i in 0..<marr.count {
         let vc = marr[i] as! UIViewController
         let vcName = type(of: vc)
         let PurposeVCName = type(of: 指定控制器名称())
         if "(PurposeVCName)" == "(vcName)" {
              self.navigationController?.popToViewController(vc, animated: true)
         }
    }
    let marr = NSMutableArray.init(array:(self.navigationController?.viewControllers)!)
    for i in 0..<marr.count {
        let vc = marr[i] as! UIViewController
        let vcName = type(of: vc)
        let PurposeName = type(of: 指定控制器的后一个控制器名称())
        if "(PurposeName)" == "(vcName)" {
           let popVC = self.navigationController?.viewControllers[i-1]
           self.navigationController?.popToViewController(popVC!, animated: true)
        }
    }
    //将本控制器从导航栏控制器数组中移除,从而返回到跳转到本控制器的控制器
    let marr = NSMutableArray.init(array(self.navigationController?.viewControllers)!) let removeArr = NSMutableArray() for i in 0..<marr.count { let vc = marr[i] as! UIViewController let vcName = type(of: vc) let selfName = type(of: self) if "(selfName)" == "(vcName)" { removeArr.add(vc) } } if removeArr.count > 0 { for i in 0..<removeArr.count { let vc = removeArr[i] as! UIViewController marr.remove(vc) } } let array : NSArray = marr self.navigationController?.viewControllers = array as! [UIViewController]
  • 相关阅读:
    R语言基础入门
    调用arcpy包批量进行矢量掩膜提取
    一些js面试高频知识点的总结
    js实现五子棋人机对战源码
    编程题汇总,持续更新
    颜色字符串转换
    根据包名,在指定空间中创建对象
    JavaScript中[]+[] 、[]+{}、{}+[]、{}+{}的结果分析
    CSS命名规范
    谈谈浏览器的兼容性
  • 原文地址:https://www.cnblogs.com/HMJ-29/p/6768574.html
Copyright © 2011-2022 走看看