I am working on a single-view app that has a UITapGestureRecognizer. I noticed that when I tried it on my iPad, the taps weren't being recognized. After I zoomed the app with the 1x/2x button, the taps started working. What am I doing wrong?
I have narrowed this down to a very small sample. I started with the XCode "Single View Application", and the following is the viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
info = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)];
[self.view addSubview:info];
tapper = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleTap:)];
[self.view addGestureRecognizer:tapper];
}
Here is what I know so far:
Works on iPhone-sized screens.
Works on iPad in portrait orientation.
Fails on iPad in landscape orientation, until the view is zoomed with 1x/2x, then it starts working (and continues working after zooming back to the original zoom level).
Exhibits the same behaviour with the iPad simulator.
The complete code is in a GitHub repository so you can view the whole thing or try it. XCode 4.5.1, iPad retina, iOS 6.0.1.
I have found that if I remove all of the entries under "Supported interface orientation" in the app's plist, this problem goes away. Or if you check the "Hide during application launch" option for the "Status Bar" settings on the Summary screen of the Target settings, this also fixes it:
There's no logical reason that I can see that either of these options should fix this bug, but they both do.
Obviously, if you do play around with the "Supported interface orientation" option, in iOS 6, you can still programmatically control the permitted orientations via supportedInterfaceOrientations (shouldAutorotateToInterfaceOrientation: in iOS 5).
Related
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!
I've run into an issue with the media picker on iOS 8.
I have an iPad application, landscape mode supported only.
The following code works just fine under iOS 6 and iOS 7, but on iOS 8, it presents the media picker in landscape mode, but a vertical gradient line appears along the right side of the picker, where the portrait version would have its right edge. The picker works fine also to the right of this line, but I cannot figure out, how to make this gradient go away.
- (void) viewDidAppear:(BOOL)animated
{
MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
[self presentViewController:mediaPicker animated:YES completion:^{
}];
}
I'd appreciate your expert help ;
In my case the solution was changing the Orientation in the Deployment info. I had to uncheck the "Landscape" box. Of course now the orientation is not fixed but at least the "black gradient" problem was solved.
I'm updating an existing app for iOS7. The app uses a UIToolbar with two UIBarButtonItem's, one on the left, the other on the right.
The left UIBarButtonItem works as expected. The right UIBarButtonItem does also, except in landscape orientation on iOS7. It works fine in iOS6 (all orientations), and in portrait mode (only) in iOS7. I'm seeing this in both the simulator and on my iPad mini.
The button is obviously correctly bound to a segue (since it usually works), and I have confirmed that it is enabled even when it is not working. (My view controller has an update timer, and I log the state on every tick.)
Has anybody else seen something like this? Any ideas?
TIA,
Doug K;
I have created an iOS6 "Single View" iPhone application.
The application is portrait only.
I added iAds to the application.
I add additional views to the application like this:
if (self.menuChoiceInstance == nil) {
self.menuChoiceInstance = [[NJDViewControllerMenuChoice alloc] initWithNibName:#"NJDViewControllerMenuChoice" bundle:nil];
self.menuChoiceInstance.delegate = self;
}
[self.view addSubview:self.menuChoiceInstance.view];
Everything seemed to work fine.
I then added universal/iPad support. Including the following line when I add my subview:
[self.menuChoiceInstance.view setFrame:CGRectMake(0, 0, self.view.frame.size.width,
self.view.frame.size.height)];
Now I get issues with iAds.
When pressing an iAd on the the rootViewController the iPad rotates to landscape. It then rotates back to portrait on closing the advert.
However pressing an iAd on the iPad on a subview makes the view rotate to landscape, and it stays landscape on closing. This destroys my user interface.
This iPad issue is the main problem, but I now also occasionally see issues with the iPhone view too, which could be related.
The iAd banner at the bottom of the screen showing the test ads sometimes has giant text and icons within it, making them overlap each other and impossible to read. Pressing the iAd rotates the phone to landscape (again in a portrait only app), yet the iAd shows the advert as if it is still portrait, with stretched content that goes off the bottom of the screen.
Similar issue here. Hard to find out what was it because i used a third party API. My problem was solved by adding my UIView as child to the rootViewController. Then my view begin to respond all main window changes. Just a line like this somewhere along viewDidLoad of myUIViewController (or as many as you have).
[myUIWindow.rootViewController addChildViewController:self];
Similar issues...
iAd Landscape Strange View Behavior
Force ADBannerView to rotate (Not "orientation" but actual transform)
iAd banner rotates my view to landscape
I believe the issue was caused by the fact that I was adding subviews onto my current view, rather than switching views.
I have changed the code that adds a subview from:
[self.view addSubview:self.statsInstance.view];
to code that presents a view.
[self presentViewController: self.settingsInstance animated:YES completion:nil];
This seems to have resolved my issue, as well as some other issues with iAd delegation methods (bannerViewActionDidFinish was called straight after the ad loaded.)