隐藏 iPhone 应用程序状态栏的问题,包括屏幕截图

发布于 2024-09-25 15:29:09 字数 271 浏览 1 评论 0原文

当我尝试隐藏状态栏时,我收到这条蓝线,我在 RootViewController

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

https://i.sstatic.net/GBCgX.png

Im getting this blue line when i try to hide the status bar, I'm using the following line in the touchesBegan method in my RootViewController

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

https://i.sstatic.net/GBCgX.png

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

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

发布评论

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

评论(4

秋千易 2024-10-02 15:29:09

这真的很简单。忘记编码吧。只要一开始就做,这会让事情变得更简单、更不那么混乱。我一直为我创建的每个应用程序执行此操作。

在 xcode 中进入您的项目,然后在“组和文件”部分中找到一个名为 yourapplicationname-info.plist 的文件。

双击它会打开一个框。它以表格的形式包含文件的属性。单击最后一行一次,使最后一行以蓝色突出显示。单击右端的加号箭头。这将添加一个新行。出现一个列表,向下滚动到状态栏最初隐藏,然后单击 Enter 将其选中。然后名称旁边会出现一个空框。勾选该框并单击 CDM+S 保存 plist。关闭盒子并返回 xcode。现在,将您尝试隐藏状态栏的代码删除。

然后单击视图,即 .xib 文件,然后用鼠标单击实际视图,使其成为焦点(我们当前正在查看的窗口)。然后点击 cmd+3 打开属性部分。在状态栏显示的地方选择选项并选择未指定。现在这将消除 uiview 上的状态栏。选择该选项后可能发生的情况是将实际视图的大小减小 20 像素。这就是状态栏的高度。您想要做的是重新调整视图以补偿丢失的状态栏。因此,我们的焦点仍然集中在视图上。点击 cmd+3 这将打开视图大小。将 H(高度)从 300 更改为 320。这将通过添加我们因删除状态栏而丢失的 20 个像素来重新调整屏幕。然后保存并关闭界面生成器,就完成了。

希望这有帮助
如果有的话请告诉我。谢谢

PK

Thiis is really simple. forget about coding it. just do it right at the beginning this make it a lot more simple and less messier. I do it all the time for every single application I've created.

Go into your project in xcode, then in the Groups and Files section find a file called yourapplicationname-info.plist.

Double cick that and a box opens. It contains properties for your file in the form of a table. Click on the last row once so that the last row is highlighted in blue. Click on the plus arrow on the right end. This will add a new row. A list appears, scroll down to Status bar is initially hidden and click enter to select it. Then an empty box appears next to the name. Tick the box and click CDM+S to save the plist. close the box and get back into xcode. Now take your code off where you try to hide the status bar.

Then click on the view, the .xib file and click with your mouse the actual view so it is in focus (the window that we are currently looking at). Then hit cmd+3 to open up the attributes section. Where it says status bar select the option and select unspecified. Now this will get rid of the status bar on the uiview. What might happen after selecting that optiion is decrease the size of the actual view by 20 pixels. thats the height of the status bar. what you want to do is readjust the view to compensate for the missing status bar. so while still having the view in our focus. hit cmd+3 this will open up the view size. change the H (height) from 300 to 320. And this will readust the screen by adding the 20 pixels which we lost by removing the status bar. Then save and close interface builder and youre done.

Hope this helps
Let me know if it does. Thanks

PK

撞了怀 2024-10-02 15:29:09

如果您的视图控制器嵌入在导航控制器中:

[CODE]self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);[/CODE]

将其放入视图 did load 方法中在您的应用程序看到的第一个视图控制器上。终于有办法解决这个令人沮丧的问题了!!!!

If your view controller is embedded in a nav controller:

[CODE]self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);[/CODE]

Put that in the view did load method on the first view controller your app sees. Finally a solution to this frustrating problem!!!!!

金橙橙 2024-10-02 15:29:09

看来您必须调整视图以占据以前由状态栏占用的空间。您可以在 Interface Builder 中使用 springs 和 struts 来完成此操作,或者您可以在调用 setStatusBar: withAnimation: 之前或之后调整视图的框架。

It looks like you have to adjust you view to take up the space formerly occupied by the status bar. You can probably do this using springs and struts in Interface Builder, or you can adjust the view's frame just before or after your call to setStatusBar: withAnimation:.

最好是你 2024-10-02 15:29:09

k 那么你必须在 appdelegate 类中执行

    [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

它对我来说效果很好...希望这会对你有所帮助≥

k then you have to do in appdelegate class

    [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

it works fine for me... hope this will help you≥

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