• 关于视图切换


    今天在写代码中突然遇到一个问题,自以为在一个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出来了。

     

     
  • 相关阅读:
    CSS 之 @media
    How to fix “Duplicate sources.list entry …” issue
    shell脚本加不加export的区别
    过滤部分错误信息,不输出到stderr
    /dev/null 2>&1 解释(转)
    crontab与环境变量
    PHP实现斐波那契数列非递归方法
    有反斜杠时候,CakePHP往pgsql插入数据异常
    PHP输出图片文件,实现浏览器缓存机制
    sudo: unable to resolve host XXX 解决方法
  • 原文地址:https://www.cnblogs.com/lyanet/p/2785254.html
Copyright © 2020-2023  润新知