zoukankan      html  css  js  c++  java
  • 关于视图切换

    今天在写代码中突然遇到一个问题,自以为在一个UIPickPhotoViewController切换到VideoPageViewController中,UIPickPhotoViewController和VideoPageViewController都是MainViewController  pushViewController方法推出来的,因此在UIPickPhotoViewController中写的代码如下:

    VideoPageViewController *VideoController = [[VideoPageViewController alloc] init];
                [self.navigationController popViewControllerAnimated:NO];
                [self.navigationController pushViewController:VideoController animated:YES];
                [VideoController release]; 

    结果这样根本就push不出来VideoController,后来才发现,原来是因为当你执行[self.navigationController popViewControllerAnimated:NO];这句代码的时候,你就把自己给pop掉了,所以self.navigationController 应该为nil了,再来执行 [self.navigationController pushViewController:VideoController animated:YES];应该是没效果了。所以想要然[self.navigationController pushViewController:VideoController animated:YES];这句代码有效,只要把self.navigationController 临时的保存起来就OK了。把上面的代码改成:

     VideoPageViewController *VideoController = [[VideoPageViewController alloc] init];
                UINavigationController *tmpNavController = self.navigationController;
                [tmpNavController popViewControllerAnimated:NO];
                [tmpNavController pushViewController:VideoController animated:YES];
                [VideoController release];  

    这样VideoController就能够被push出来了。

     

     
  • 相关阅读:
    docker容器升级脚本
    Haproxy状态监控配置教程
    负载均衡之Haproxy配置详解(及httpd配置)
    升级代码脚本
    升级数据库脚本(加入事务)
    监控端口,新疆模拟用户登录脚本
    mongodb3.2系统性学习——3、update()操作
    Java Socket编程
    php错误级别设置
    php 用于绘图使用的颜色数组
  • 原文地址:https://www.cnblogs.com/lyanet/p/2785254.html
Copyright © 2011-2022 走看看