zoukankan      html  css  js  c++  java
  • 强制旋转iPhone界面

    在现在的ios sdk中,我们一般通过UIApplication的setStatusBarOrientation:来进行View的强制旋转
    (当然,还要配合- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation),
    但是,setStatusBarOrientation并不一定马上会执行shouldAutorotateToInterfaceOrientation进行界面旋转,
    这时,有个小技巧可以让界面马上旋转过来,那就是调用一下 UINavigationController的presentModalViewController:animated:
    {
    //为了马上旋转过来
    UINavigationController* nav = [[GurgleAppDelegate getAppDelegate] navigationController];
    UIViewController *controller = [[UIViewController alloc] init];
    UINavigationController *parentController = [[UINavigationController alloc] initWithRootViewController:controller];
    [nav presentModalViewController:parentController animated:NO];
    [controller dismissModalViewControllerAnimated:NO];
    [parentController release];
    [controller release];
    }

    // Override to allow orientations other than the default portrait orientation
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return viewOrientation == interfaceOrientation;
    }
    注意:这样做导航栏会消失,但是可以通过自定义导航栏来显示导航的效果

  • 相关阅读:
    java 内部类
    webservice restful rpc
    linux 修改文件权限chmod
    java ThreadLocal的理解
    转:Eclipse常用开发插件
    Eclipse安装插件支持jQuery智能提示
    转:VS2008 vs2010中JQUERY智能提醒
    jquery ui和jquery easy ui的区别
    线程池
    java连接数据库URL
  • 原文地址:https://www.cnblogs.com/foxmin/p/2498150.html
Copyright © 2011-2022 走看看