• 视图push和presentViewController注意点


    presentViewController:

    - (void)publishClick{
        
        NSLog(@"发布按钮被点击");
        PublishViewController *publishVc = [[PublishViewController alloc]init];
    // 包装创建导航控制器 MainNavigationController *nav = [[MainNavigationController alloc]initWithRootViewController:publishVc]; // 这里不能使用self来弹出其他控制器, 因为self执行了dismiss操作 UIViewController *root = [UIApplication sharedApplication].keyWindow.rootViewController; [root presentViewController:nav animated:YES completion:nil]; }

     

    pushViewController:

     // 在视图中push,需要取到导航控制器

    // 先取得TabBarViewController UITabBarController *tabBarVc = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    // 再取得导航控制器
    // 以下一条语句:This may return the "More" navigation controller if it exists.
        UINavigationController *nav = (UINavigationController *)tabBarVc.selectedViewController; 

    [nav pushViewController:webVc animated:YES];

      

  • 相关阅读:
    工坊第五天
    工坊第四天
    工坊第三天
    工坊第二天
    工坊第一天
    莫队 优雅暴力出奇迹
    状压 DP 总结
    关于MatlabGUI清除WorkSpace的用法
    ArduinoNano卡在上传,无法烧录
    两轮差速驱动机器人的坐标轨迹计算
  • 原文地址:https://www.cnblogs.com/pengsi/p/5728571.html
Copyright © 2020-2023  润新知