如何删除“基于视图的应用程序”中的状态栏- iOS

发布于 2024-11-17 09:15:35 字数 564 浏览 10 评论 0原文

这是我试图习惯使用 XCode4 的一部分...

好吧,所以我在 XCode 4 中创建了一个新项目,并使用了基于视图的应用程序模板;我希望构建新的应用程序,因为苹果希望我使用这个模板。

所以我使用的是从 AppDelegate 调用的自动创建的视图控制器(到目前为止我还没有触及任何东西)。现在,我想删除状态栏。据我了解,我应该做的是转到查看 XIB 并在属性检查器中将状态栏字段设置为 < strong>无(到目前为止我都是这样做的),但是当我运行应用程序时,状态栏仍然在那里(!)。

我还尝试在 ma​​inWindow.xib 文件上执行相同的操作(将 STSTUS BAR 属性设置为“无”),并且应用程序运行时会使用此栏来阻挡我的视线...

有人吗?

在此处输入图像描述

This is a part of me trying to get used to working with XCode4...

OK, so i've created a new project in XCode 4 and I used the View Based Application template; I wish to build the new app as Apple intended me to use this template.

So I'm using the automatically-created-view-controller which is called from the AppDelegate (so far I haven't touched anything). Now, I want to remove the STATUS BAR. As far as I understand, what I should do, is go to the view XIB and in the Attributes Inspector set the Status Bar field to None (this is how I used to do it so far), but mercilessly when I run the application the STATUS BAR is still there (!).

I also tried to do the same thing on the mainWindow.xib file (the setting the STSTUS BAR attribute to None thing) and the app runs with this bar that blocks my view...

Anyone?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我爱人 2024-11-24 09:15:35

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

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

如果您在应用程序委托中执行此操作,则可以这样写:

    [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:

隐藏或显示状态栏,
可选择为过渡设置动画。
- (void)setStatusBarHidden:(BOOL)隐藏
withAnimation:(UIStatusBarAnimation)动画
参数

隐藏

YES 隐藏状态栏,NO 显示状态栏。动画片

一个常量,指示是否应该有动画,如果

请求一个,是否应该
淡入或淡出状态栏或
是否应该滑动状态栏
进或出。

讨论

参见常量说明
UIStatusBarAnimation 类型的
更多信息。可用性

* 适​​用于 iOS 3.2 及更高版本。

因此,如果您对动画部分不感兴趣,我建议使用此:

状态栏隐藏

一个布尔值,决定
状态栏是否隐藏。
@property(非原子,
getter=isStatusBarHidden) BOOL
statusBar隐藏返回值

YES表示状态栏隐藏;不
意味着它是可见的。可用性

* 适​​用于 iOS 2.0 及更高版本。

If you read the "header" you will see "Simulated metrics". Those properties are only to simulate visual elements when you lay out your code with interfacebuilder.

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

If you do it in the Application Delegate you write:

    [application setStatusBarHidden:YES animated:NO];

in this method:

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

EDIT

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

Requested in comment, from documentation:

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.

So if you are not interested in the animation part I suggest using this:

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文