IOS7中的状态栏和导航栏问题 [英] Status bar and navigation bar issue in IOS7

查看:85
本文介绍了IOS7中的状态栏和导航栏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的应用程序迁移到iOS 7.对于处理状态栏问题,我添加了此代码

I am migrating my application to iOS 7. For handing the status bar issue I have added this code

if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f)
{
    CGRect frame = self.navigationController.view.frame;
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        frame.origin.y = 20;
    }
    else
    {
        frame.origin.x = 20;
    }
    [self.navigationController.view setFrame:frame];
}

这在正常情况下工作正常。如果我正在更改方向(应用程序仅支持横向)或呈现任何视图控制器并关闭模型视图控制器,我的视图控制器对齐方式已更改。状态栏再次与我的视图控制器重叠。这段代码根本不起作用。请指导我修复此状态栏问题。

This is working fine in normal case. If I am changing orientation (app supports only landscape orientation) or presenting any view controller and dismissing model view controller my view controller alignment changed. The status bar again overlaps my view controller. This piece of code is not working at all. Please guide me to fix this status bar issue.

案例2:这就是我呈现视图控制器的方式

Case 2: This is how I am presenting my view controller

ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    reader.supportedOrientationsMask = ZBarOrientationMaskLandscape;
else
    reader.supportedOrientationsMask = ZBarOrientationMaskPortrait;

    [self presentModalViewController:reader animated:YES];

参考:

提前致谢。

推荐答案

修复IOS 7中的状态栏问题

最后,我使用xcode5中的delta值属性修复了状态栏。首先,我有增加的起源 - 对于Xib中使用的所有控制器来说是20pxl (它的接缝仅在IOS 7中正常工作),之后我为所有视图设置delta值控制器原点-y到-20它在ios 6和IOS 7中都能正常工作

Finally i fixed the status bar over lap issue using the delta value property in xcode5. First i have increased origin - y 20pxl to all the controller used in the Xib(it seams to be working fine only in IOS 7), after that i set the delta value for all the view controller origin -y to -20 it works fine in both ios 6 and IOS 7.

执行此操作的步骤。

Xcode 5提供预览选项,可根据操作系统版本查看不同视图中xib的外观。

从助理编辑器中选择预览选项

choose preview option from assistant editor

点击助理编辑器

并选择预览选项以预览所选视图控制器在不同的版本。

and choose preview option to preview selected view controller in different version.

view控制器视图预览选项。

view controller view preview option.

在预览中,您可以找到切换选项以预览不同版本的视图。在预览中,如果通过切换版本未正确修复状态栏,则可以清楚地感觉到状态栏问题。

in preview you can find the toggle option to preview view in different version. In preview u can feel the status bar issue clearly if its not fixed properly by toggle the version.

修复状态栏问题的三个步骤:
第1步:确保视图定位我们7.0及更高版本在文件检查器中。

Three steps to fix the status bar issue: step 1: Make sure the view target us 7.0 and later in File inspector.

步骤2:为视图控制器中添加的所有控件增加原点 - y为20像素(正好是状态栏的大小)。

Step 2 : Increase the origin - y with 20 pixel (exactly the size of the status bar) for all the controls added in the view controller.

步骤3:将所有控件的原点y的增量值设置为-20 然后仅根据版本自动调整。现在使用预览,感受控件因delta值而自动调整的差异。

Step 3 : Set the delta value of origin y to -20 for all the controls then only it will adjust automatically based on the version. Use preview now and feel the differ that the controls automatically adjust because of the delta value.

状态栏问题解决后,在显示模型视图(ZbarSDk控制器)时发出的问题也会自动修复。

预览屏幕:

这篇关于IOS7中的状态栏和导航栏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆