This is a strange issue that may be related to all the orientation issues I'm seeing in iOS8.
I have a universal app. The iPad version supports only landscape and the iPhone version supports only portrait.
When a user opens the iPad version, it opens in landscape mode, which is expected. However, every control on the right side of the view is unresponsive to user touch events. The affected area is 256 wide, and the area on the left that 'works' is 768 wide (portrait width). Therefore, even though the app opens in landscape, the app thinks it's in portrait. Since the phone version only supports portrait, the issue doesn't reveal itself there, though I believe the issue is not device specific, however, the issue only affects devices running iOS8.
The app was originally developed for iOS4 and has gone through several iterations since. However, much of the original code and nibs are still in use. Other orientation issues have shown up with iOS8 and could be related, or not, who knows?
Since the app was originally designed for iOS4, storyboards were not used, and still aren't. I have checked some things: made sure all nibs have 'Auto resize subviews' checked, and made sure that only landscape orientations existed in the app plist (verified in XML). Here is a code snippet from AppDelegate didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[self.window setFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[AppMainViewController alloc] initWithNibName:nib bundle:nil];
//...
return YES;
}
In the image, I'm showing both portrait and landscape sizes. As I mentioned earlier, the view controller renders and looks as it should in landscape, but anything in the red area of the image is unresponsive to user taps.
Perhaps I've looked at this issue too long and hopefully somebody has some insight on why this is happening. Anyone? Thanks!
Related
I'm in the process of upgrading a 10 years old iOS application (Objective-C) for iOS 13 (Xcode 11.4) and noticed the following strange issue: When the app is launched while the iPhone (Simulator, 13.4) is in landscape orientation, the app's window has the correct dimensions, but is strangely rotated 90 degrees to the right. This does not happen on iPad (Simulator, 13.4) or iPhone Simulator 12.x where the app launches correctly.
Attached is a screenshot to better illustrate the issue.
The app is using XIBs and programmatically created views, no storyboards.
The initial view is created in application didFinishLaunchingWithOptions in the usual way:
[self.window addSubview:tabBarController.view];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
The tabBarController is loaded from a XIB.
The Launch Screen (which is the only storyboard in the app) is shown correctly.
Any ideas?
Turns out that removing the line
[self.window addSubview:tabBarController.view];
in application didFinishLaunchingWithOptions did the trick. Apparently this line was needed once, but causes havoc now.
Removing the line also fixed the Unbalanced calls to begin/end appearance transitions for <UITabBarController: ...> message I was seeing in the log output.
See also this answer in the Apple Developer Forums which brought me on the right track.
I have a couple of older Cocos2d games that, when updating, I noticed appear truncated upon launch. Having found other answers here on StackOverflow I am still having issues.
The workaround I currently use is;
Inside AppDelegate.m I am using
CGAffineTransform transform = CGAffineTransformMakeRotation(1.57079633);
navController_.view.transform = transform;
And setting the device orientation to Portrait & Portraitupsidedown - even though the game is Landscape.
This is a dirty fix, and brings it's own set of issues, such as UIAlert views not appearing at the correct orientation, as well as the screen not rotating landscape upside down (unless you hold it portraitupsidedown) which gets confusing, and pretty sure it is against Apple's review rules and just make the whole workaround useless really.
Effectively I need to trick it so that I can enable Landscape mode rather than Portrait, yet rotate the screen on launch, has anyone managed this successfully?
Add this in AppDelegate.m class
(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscape;
}
Project file -> 'Targets' -> Choose you orientation to Landscape
I have a universal iOS app and currently I am developing it for iPad.
When I am launching the app in the portrait mode app launches fine. But when I launch in landscape mode, portion of the screen becomes back and the app is not launched in landscape mode. I have used
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll; }
- (BOOL)shouldAutorotate {
return YES;}
but the app is not launching in landsape mode and having a black screen portion. I have attached a screen shot as well.. What is the problem here and how to get rid of this?
Try this, write this in ViewDidLoad, We need to set the insets for self.view
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
{
self.edgesForExtendedLayout=UIRectEdgeNone;
}
Since your view is rotated correctly (the text is upright) you can assume that this problem is not a rotation problem but instead a problem with your layout code/interface builder.
To solve this make sure you pinned your content view to all edges of his superview
I had the same problem when iOS8 comes out. With iOS7 all worked fine. After spending a lot of time try to solving i just find that replacing the "launch xib" with a storyboard fix my problem.
So try to add a storyboard, put your actual initial xib into and restart. Don't forget to specify the inizial storyboard into your project's info.
NB you probably have this problem on iPhone6+ as well because it is capable of running springboard in landscape.
I rarely (pretty much never) use storyboards or nibs, so I've had this problem since iOs7 in applications which support rotation. I set up my viewControllers in loadView or viewDidLoad and at that point the viewController does not know the interfaceOrientation. Because I usually handle rotation programatically as well I just do something like this in viewWillAppearAnimated:
{
BOOL landscape = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication]statusBarOrientation]);
BOOL ios8 = NSClassFromString(#"UIPopoverPresentationController")!=NULL;
if (landscape&&ios8) {
[self willRotateToInterfaceOrientation:[[UIApplication sharedApplication]statusBarOrientation] duration:0.0];
}
}
Just solved similar problem by setting UIMainStoryboardFile for my app (although this has no side effects on my app as I am setting my ViewControllers in code). So setting main storyboard file has fixed this for iOS 8 through 10.
So set both launch screen and your main interface storyboards.
Setting NSMainNibFile have not fixed that problem for me. Only storyboards.
Main storyboard should contain at least initial view controller that could be empty.
In the appDelegate, set:
[self.window setFrame:[[UIScreen mainScreen] bounds]];
in the didFinishLaunchingWithOptions
I have a universal project for iOS that was created in xCode 5 that I am trying to port to xCode 6. Everything seems to have been fine since I am not using LaunchScreen and iPhone 6 and 6 Plus scale the application to their resolutions.
The problem occurs when device changes its orientation.
Scenario:
It only occurs on iPhone 6 and 6 Plus.
Open Login screen with username and password fields. Rotate the device to Landscape, and tap username or password field. The keyboard appears in the middle of the screen with half cut. Rotating back to portrait hides the keyboard altogether and it no longer appears on screen no matter which field you tap on.
To get the keyboard back, rotate back to Landscape, tap on a field rotate device to opposite Landscape (don't let it go in Portrait). The keyboard suddenly becomes normal and acts fine.
I got the same problem, and that's because your app is launched in scaled mode.
It seems that Apple didn't go the full blown way to handle landscape in this scaled mode.
The solution is to switch to non-scaled mode for the iPhone 6-6Plus, using the trick specified here: How to enable native resolution for apps on iPhone 6 and 6 Plus?
Note that this will likely break a lot of your screens in the process.. but there's no other solution.
I have faced this issue with scalable mode of the app. Though supporting non-scalble mode (by adding iPhone 6 & 6+ launch images to xcassets) solves this problem, it was not permissible in my case as screens had static layout for each orientation.
I could solve this problem by avoiding the incidents of changing the root view controller of the window. Instead, the new view controllers have been added (with balancing removal) as subview (and hence childViewController) to the existing root view controller.
Everything is ok on iOS6/7, But not iOS8.
The orientation of the keyboard on iOS 8 is not the same as status bar.
If your application runs only portrait mode you can stop generating orientation notifications;
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
I have faced this issue, and after some research I found some stuff, that caused such bug.
In my AppDelegate I changed window rootViewController to show different ViewControllers depends of authorization status
if (!auth)
{
self.window.rootViewController = [[AuthViewController alloc] init];
} else {
self.window.rootViewController = [[DataViewController alloc] init];
}
I removed this and move controller select logic to NavigationViewController
if (!auth)
{
self.viewControllers = #[[[AuthViewController alloc] init]];
} else {
self.viewControllers = #[[[DataViewController alloc] init]];
}
and make this NavigationViewController as Storyboard initial view controller.
Hope it helps!
since iOS 8 my App runs quite good, but I found a Problem while testing this app.
It just happens on iPad and only if I launch the app in landscape mode. If it launches in Portrait everything is right(no rotation issues). If i rotate the Device (simulator or real device) the view rotates out of the screen and just shows a Cut of the real view and the rest is black.
Anyone else did notice such a bug? How can I fix it?
Had similar problem. Surprisingly the fix was to comment out all the code related to self.window on Appdelegate.
Commented initialising of self.window and its assignment. Set the initial view in storyboard in Attributes inspector by checking "Is Initial View Controller" checkbox.
New Better Solution
Commenting self.window was causing other issues. Instead the below code is best:
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
[UIViewController attemptRotationToDeviceOrientation];
}
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(#"Currently landscape: %#, width: %.2f, height: %.2f",
(landscape ? #"Yes" : #"No"),
[[UIScreen mainScreen] bounds].size.width,
[[UIScreen mainScreen] bounds].size.height);
And the results are:
For iOS 8+
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00
and for iOS 7-
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
It seems like there is a change in the way height and width of the screen is handled while in portrait and landscape from ios8 onwards.
Check this link
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
UPDATE - We found a fix:
I found the answer to our problem which as described below appeared to be exactly the same as yours. One of our other developers noticed an "unexpected nil in main window" when attempting to tap on the far right of the screen. This led me to do a new search and I found this thread on stackoverflow that actually contained the answer to our problem.
( here is the link to the question which help my answer: unexpected nil window in _UIApplicationHandleEventFromQueueEvent )
The actual answer came from frankish who suggested opening the main.xib (or main storyboard) and clicking on the Window in that and making sure that the "Visible at Launch" and "Full screen at Launch" properties are checked (set to true.)
In our case, it was JUST the "Full screen at Launch" property that needed to be set, but setting this fixed the rotation problem we were seeing AND it fixed an issue where when launching on iPad in landscape the far right of the screen was not touchable.
END UPDATE - (original non-answer below)
My answer isn't an answer, but I have run into the exact same issue. On rotate in our app, when building with Xcode 6, I see the exact same rendering issue as the the screenshots on this question. The exact same out of position rotate with black bars at the side and bottom. (Our app on iPhone doesn't support any rotation so we don't see the issue on iPhone. On iPad we support landscape left and landscape right. When rotating from one to the other, when the iPad does it's standard rotation animation, it will rotate out of position (showing the black bars) when going one way and then rotate back into proper position when going back to the other supported orientation. I don't believe it's related to any custom positioning or animation code. It happens with every screen, including the splash screen. It appears to be related to the built in Apple screen rotation. Obviously not every project has this issue in iOS but I have not come across the particulars that are causing this issue. I spent all day yesterday researching the issue and going through our code and I have nothing.
One piece of additional info. If I build with Xcode 6 and run on a device with iOS 7 then there is not issue. This issue ONLY happens when I build with Xcode 6 and run on a device with iOS 8.
Here is a link to my own question posted yesterday about this issue. (I did not come across this question until after I'd posted my question.)
Building project with Xcode 6 (iOS 8 SDK) causes landscape rotation rendering issue on iPad
I found this to be an issue when I had multiple windows in my application. By setting a breakpoint on -[UIWindow setFrame:], I was able to see that upon rotation, the system was giving me giving me an erroneous frame size and position. You can get around this by manually setting your frame to equal [UIScreen mainScreen] bounds] which seems to be correct if you running on iOS7+ and compiling with Xcode6. I found that doing this in -[UIWindow becomeKeyWindow] worked well for me:
- (void)becomeKeyWindow {
[super becomeKeyWindow];
self.frame = [UIScreen mainScreen].bounds;
}