iPhone how to create a full screen app?

最后都变了- 提交于 2019-12-03 05:46:08

问题


I've been trying to create a full screen view. I plan on using core graphics for rendering. I am new to iPhone development so please forgive this basic question.

Here's my setup code;

- (void)loadView
{
    CGRect  rect = [[UIScreen mainScreen] bounds];
    GameView *main_view;
    main_view = [[GameView alloc] initWithFrame:rect ];
    main_view.clearsContextBeforeDrawing = NO;
    self.view = main_view;
    [main_view release];    
}

Yet when I run this I get a thin status bar at the top with the time and battery level.

I tried looking for some samples yet all the samples were opengles.

Could someone please tell me where I'm going wrong? And just how to create a full screen view.

Thanks


回答1:


There are two methods;

In the info.plist for your application add a boolean key UIStatusBarHidden and set it to true.

At runtime you can call setStatusBarHidden on your application to show/hide the status bar. E.g.

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



回答2:


Since I just found the answer I was looking for here, I may as well add that the above method is now depreciated. The modern method is:

- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation

Thanks!




回答3:


You may also want to make your rect = [[UIScreen mainScreen] applicationFrame]




回答4:


Add below method in respective view controller

-(BOOL) prefersStatusBarHidden

It worked for me.




回答5:


This works and it is the easiest

UIViewControllerBasedStatusBarAppearance : NO in the .plist



来源:https://stackoverflow.com/questions/620386/iphone-how-to-create-a-full-screen-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!