当前位置:编程学习 > wap >>

ios7下使用presentViewController会出现ViewController遮挡住状态栏的问题

ios7下使用presentViewController会出现ViewController遮挡住状态栏的问题


        TCWBRebroadcastMsgViewController *tCWBRebroadcastMsgViewController = [[TCWBRebroadcastMsgViewController alloc] initWithEngine:self parameter:dic];
        UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:tCWBRebroadcastMsgViewController];
        [rootViewController presentViewController:nvc animated:YES completion:nil];


在IOS7下会出现如下问题,怎么解决?

--------------------编程问答-------------------- 楼主应该是代码写的UI吧?从iOs7开始,{0,0}为屏幕最左上角点,包括了状态栏,所以你可以预定义一个变量:
#define UI_DEFAULT_ORIGIN_Y (IS_IOS_7 ? 64.0f : 0.0f) --------------------编程问答--------------------
引用 1 楼 sinom 的回复:
楼主应该是代码写的UI吧?从iOs7开始,{0,0}为屏幕最左上角点,包括了状态栏,所以你可以预定义一个变量:
#define UI_DEFAULT_ORIGIN_Y (IS_IOS_7 ? 64.0f : 0.0f)

不是啊,那你导航条怎么办?
你的视图是从下弹出的,不是PUSH进来的。导航条顶到最上面去了,怎么改他得位置? --------------------编程问答--------------------  嗯,我也才发现这个问题,你是直接设置navigationBar的backgroundimage是吧?现在我试了改成:
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.view.width, 45.0f)] autorelease];
    imageView.image = [UIImage imageNamed:@"top_bg"];
    [self.navigationController.navigationBar addSubview:imageView];
但感觉这样做并不好,比如这样会盖着title,正在找更好的办法
--------------------编程问答-------------------- 主要是原来的程序与ios7版本兼容的问题,你可以尝试加上下面的代码

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
        self.automaticallyAdjustsScrollViewInsets = YES;
    }
#endif
--------------------编程问答--------------------
#define IsIos7 ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)

  -(void)shipeiForIos7
{
    if (IsIos7) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
}
在.plist中设置这个属性Status bar style为Transparent black style(alpha of 0.5);应该就没问题了,lz可以试试看行不行。
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,