Unable to start my application in full screen on i

2019-02-02 00:59发布

问题:

I have added Default-568h@2x.png to my project and set it in project settings, I have also set autoresizing options for my view and elements on that view which is initially loading on my application which is landscape-only, but after running my application in iOS 6.0 Simulator Retina 4 inch I see my application moved all the way left, leaving black pixel area on the right.

Any idea what should I do beside these things in order to see my application runs in "full screen" on iOS 6.0 Simulator Retina 4 inch?


[edit #1: AppDelegate]

I also edited my AppDelegate.m like this:

viewControllerMain = [[ViewControllerMain alloc] init];
//[window addSubview:viewControllerMain.view];
window.rootViewController = viewControllerMain;

[edit #2: Editing frame]

I managed to achieve full screen mode, but it's not working as it should. I do this in my views:

CGRect frame = CGRectMake([UIScreen mainScreen].bounds.origin.x, [UIScreen mainScreen].bounds.origin.y, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
self.frame = frame;

This only brings my view to full screen, but black area on the right I mentioned on the beginning is dead and no user interaction is possible in that area (I have UIButton there which doesn't react on touch). So basically, what I did only made my view appear in full resolution, but functionality of elements on view is limited to area where my app originally showed when I first started it on Retina 4 inch simulator.


[edit #3: Changing size of UIView's in XIB files]

I even tried to change actual size of UIView's in my XIB files resizing them all to Regina 4 Full Screen, but still - same thing.


[edit #4: Changing size of window object]

I have tried to change size of window object in AppDelegate.m but again no luck. Here's how AppDelegate.m look like.

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;

mainViewController = [[MainViewController alloc] init];
window.rootViewController = mainViewController;

// Override point for customization after application launch
[window setFrame:[UIScreen mainScreen].bounds];
[window makeKeyAndVisible];

[edit #5: "Solution"]

So far I did following: In IB I made new UIViews with iPhone 5 resolution size, assigned same owner classes which are handling their equivalent UIViews made for pre iPhone 5 resolution and in code where do I need to load some of these UIViews I check [UIScreen mainScreen].borders to determine which device is currently running my application. In this way, I managed to get things work.

But still, main question remained - why didn't all my UIViews automatically stretched to new resolution after I did all those things I mentioned?

Anyhow, bounty remains active for 5 or 6 days. If someone manages to solve this issue, I'd be very grateful. If not, I'll give bounty to @onegray, since that was the thing I didn't took care of at first place, and in my current implementation it is really important.

Best regards.


[edit #6: MainWindow.xib Full Screen at Launch option]

As @user1702985 suggested, I turned this option ON as it was deselected. But no luck.

When I start my application I show one View for 2 seconds with one UIImageView on it. If I set Autosize properties right, this UIView is shown in fullscreen on iPhone 5 simulator. BUT. After that I have second UIView which contains vertical UIScrollView, UIViews as header and footer and one UIButton, and I also set all autosize options for these elements, but this UIView is shown in iPhone 4-- resolution. It really acts strange and I still don't know what can it be.


[edit #7: Auto-resizing options which are set]

This auto-resizing option is set for all my UIViews and it's elements.


[edit #8: Explanation of Full Screen at Launch option]

MainWindow.xib properties.

回答1:

Make sure that key window has proper size. Workaround is to set proper frame: [window setFrame:[[UIScreen mainScreen] bounds]].

Update:
It is difficult to guess where is the problem without having the source code. I've created simple app stub to test interface orientation for iPhone4/iPhone5. I just created new "Single View Application", added some subviews to the root view, and added "Defaults" images. I did it in Xcode 4.3.2 without any extra features of Xcode 4.5. And app automatically stretches its screen to proper size (for both portrait/landscape orientations).



回答2:

I hope this will help you but not sure that you will got touch effect in full screen, So you have to check for full touch for your application.

Step 1: Click On Project from Navigation shown in image and click on missing file

Step 2: In second image click on Add

Now run project your project will run in Full iPhone 5 screen or simulator.!



回答3:

I had the same issue of part of the screen not responding to user interaction. Selecting the "Full Screen at launch" option on the MainWindow.xib fixed it for me.



回答4:

No matter what I did, I could not get my app fullscreen.

But after I added a file "Default-568@2x.png to my app. Now all the xib's run full screen. You can quickly test this by making a new app in XCode and copying the the black png that was created.



回答5:

If you use XCode 6.1 try this solution (for projects without full image set):

  1. Project -> Target -> General -> App Icons and Launch Images -> Launch Screen file
  2. Choose xib for first screen.


回答6:

did you try this?

iOS Simulator > Hardware > Device > iPhone(Retina 4-inch)

i just run into the same problem and this is how i solved.



回答7:

How are you adding the main viewController to the window? Just adding the view as a subview isn't supported any more in iOS6.

Here's an except from an article on my blog about making apps work on the iPhone 5 screen size.

Use window.rootViewController to add your initial view

First up, if you're building your initial views in code make sure you add your initial view to the window with window.rootViewController rather than the old way of simply adding the view as a subview. If you don't do this, autorotating will not work at all for your app under iOS 6.

Here's an example:

navigationController = [[UINavigationController alloc] initWithRootViewController: myRootVC];
//[window addSubview:[navigationController view]]; Don't do this!
window.rootViewController = navigationController; // Do this instead!

More at http://pervasivecode.blogspot.co.uk/2012/09/making-apps-work-on-iphone-5-screen-size.html



回答8:

Delete App on simulator by LongPress-ing and re-run.

This works for me, after 4 inch retina adjustments. Everything was auto-resized the way I stitch-up in IB.



回答9:

Please add launch screen for application.



回答10:

We ran into a similar issue on an app that was created back in the iOS 6 days when testing on iOS 8.

The fix for us was setting the "Hidden" flag on MainWindow.xib.

This is how we found out about the fix here.



回答11:

The same was happening to me. I was trying to make a video splash screen, and since I can't control the time the splash screen is shown, and was therefore unable to show the full video, I had to make a fake splash screen, which was just a controller that was shown first and then removed. That controller's view was not being shown as fullscreen no matter what I tried. In the end, I found out it was happening because I had no splash image.

Solution: Add splash screens to your project (even if they are just black images), and the full screen problem should be fixed.