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出来了。

     

     
  • 相关阅读:
    虚拟化基础介绍
    Linux---1.06.用户和用户组管理
    1.vmware tools的安装
    5.无法更新包,yum源更换无效
    Linux---1.05.软件包管理
    4.Vim的安装及待解决问题
    NSWorkspace的mountedLocalVolumePaths
    修改系统默认的NSButton的按下变灰
    NSParagraphStyleAttributeName
    - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
  • 原文地址:https://www.cnblogs.com/lyanet/p/2785254.html
Copyright © 2011-2022 走看看