gpt4 book ai didi

ios - 如何删除 "View Based Application"中的状态栏 - iOS

转载 作者:可可西里 更新时间:2023-11-01 03:05:51 25 4
gpt4 key购买 nike

这是我努力习惯使用 XCode4 的一部分...

好的,所以我在 XCode 4 中创建了一个新项目并使用了View Based Application 模板;我希望构建新的应用程序,因为 Apple 希望我使用此模板。

所以我正在使用从 AppDelegate 调用的自动创建的 View Controller (到目前为止我还没有触及任何东西)。现在,我想删除状态栏。据我所知,我应该做的是转到查看 XIB 并在 Attributes Inspector 中将 Status Bar 字段设置为 < strong>无(到目前为止我就是这样做的),但是当我运行应用程序时,状态栏仍然存在(!)。

我还尝试在 ma​​inWindow.xib 文件上做同样的事情(将 STSTUS BAR 属性设置为 None thing)并且应用程序运行时这个栏挡住我的视线...

有人吗?

enter image description here

最佳答案

如果您阅读“标题”,您将看到“模拟指标”。当您使用 interfacebuilder 布置代码时,这些属性仅用于模拟视觉元素。

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

如果您在 Application Delegate 中执行此操作,您将编写:

    [application setStatusBarHidden:YES animated:NO];

在这个方法中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {...}

编辑

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/setStatusBarHidden:withAnimation :

在评论中要求,来自文档:

setStatusBarHidden:withAnimation:

Hides or shows the status bar, optionally animating the transition. - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation Parameters

hidden

YES to hide the status bar, NO to show the status bar. animation

A constant that indicates whether there should be an animation and, if

one is requested, whether it should fade the status bar in or out or whether it should slide the status bar in or out.

Discussion

See the descriptions of the constants of the UIStatusBarAnimation type for more information. Availability

* Available in iOS 3.2 and later.

所以如果你对动画部分不感兴趣我建议使用这个:

statusBarHidden

A Boolean value that determines whether the status bar is hidden. @property(nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden Return Value

YES means the status bar is hidden; NO means it's visible. Availability

* Available in iOS 2.0 and later.

关于ios - 如何删除 "View Based Application"中的状态栏 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6485703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com