UIButton does not receive events after rotation - objective-c

I have a view controller with an UIButton. That view controller is shown in landscape right mode only. Until iOS 8.0.2, all works fine. I'm testing with an iPhone 5S.
But after installing iOS 8.1.1, the following happens:
If I click the button just right after the view controller is shown, all works fine. The touch up inside event is received.
But if I start to rotate the phone a few times, even when the view does not change orientation (remember, landscape right only), the events are not received anymore.
Here is the relevant code:
-(BOOL)shouldAutorotate
{
NSLog(#"shouldAutorotate");
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
NSLog(#"supportedInterfaceOrientations");
return UIInterfaceOrientationMaskLandscapeRight;
}
I should mention that the method shouldAutorotate is called several times.
Thank you in advance. Any help would be appreciated.

If you use only one landscape right mode, try to detect device orientation like here:
Detecting iOS UIDevice orientation

Related

How to get rotation to work in iOS7?

I want my app to support landscape only (left and right) on iPhone and iPad.
Hence in the info.plist I added landscape as the supported orientations.
My root controller is a UINavigationController with one controller on its stack.
However, my controller also rotates to portrait but not to portrait upside down.
If I Add GetSupportedInterfaceOrientations() (supportedInterfaceOrientationsForWindow: in ObjC) to the app delegate and return landscape there, the rotation completely stops working.
How hard can it be?
Did you try to use?
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
hope this helps..
Figured it out. The topmost view controller has to return the interface orientations it wants to rotate to. In my case, that's the UINavigationController.
And the change was already in iOS6.

Annotations under callout gets triggered when touching callout on iOS 6

I'm having trouble with these annotations...
First when opening the app on iOS 6 devices the pins would show on top of the callout, which could be fixed with:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self.superview bringSubviewToFront:self];
}
from: Custom Annotation View do not work on iOS6
Now when I tap the callout, the pins underneath gets triggered closing the current callout and opens the new one.
I've have tried overriding:
touchesBegan:, touchesMoved: and touchesEnded
and not calling super within them, to prevent the call propagate to layers behind it - without any luck...
Any ideas anyone? It works fine on iOS 5...
Try setting your delegates before adding annotations - if you haven't

UIView with landscape only is turning to portrait

So I have My app running the master-detail project for iPad.
I added a UIBarButtonItem the show push a view "About App" to the detail.
When I push a third view to the detail (from the UITable) and hit the back button, it goes back to the second view on the stack of the navigationControl and the view turn to portrait!
All my viewControllers have the following code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
else
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
This is the error that appears:
The view controller returned NO
from -shouldAutorotateToInterfaceOrientation: for all interface
orientations. It should support at least one orientation.
I also tried to set Landscape on the UIView orientation directly from the Storyboard but doesn't work either.
Any leads?
I would try removing the if statements to further inspect the cause of the problem and leaving only the isLandscape check in.
After a while I realised that my third view had a slightly different code.
I just copied the code form the other views and pasted on the third and it's working now...

Interface Orientation won't change to Landscape on App Launch

i stuck on a problem that drives me crazy!
I have an iPad application starting with a TabBarViewController. Every Tab has it's own ViewController and nib-file.
To make interface orientation possible I added all orientations to my info.plist and subclassing my TabBarController to set:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Every View is autoresized and formatted well for displaying the right Orientation if I rotate the Interface. If I test it in the simulator, everything looks fine and I can rotate between the Orientations.
Now the point that drives me crazy:
If I launch the App in Portrait Mode, all works fine.. but if I launch in Landscape, I get an error and my Interface orientation seems still to be Portrait, while the Simulator is in Landscape Mode!!
The Error:
2011-05-24 21:50:15.011 Project[57995:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
I checked for Orientation like this:
-(void)viewWillAppear:(BOOL)animated{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight)) {
NSLog(#"Orientation: Landscape");
}
else{
NSLog(#"Orientation: Portrait");
}
}
The Log says it is in "Landscape" Mode if I launch in Landscape, but if I change tab to another it looks terrible because the View is displayed in Portrait mode instead.
On change back to the start-view where i asked for Orientation… the log displays "Portrait"… but the Simulator is still Landscape!
I can't figure out why the Orientation is Portrait on start,…
even if I start in Landscape…
Any idea how to solve this problem?
Ok. So the documentation says viewWillAppear: is called prior to all animations. And when your app starts, its initial orientation is Portrait. Based on what your orientation is, it then rotates to that orientation. Since it animates to the orientation off screen, this must be called after viewWillAppear:/ So when viewWillAppear: is called, its still in Portrait. I tested this myself.
I solved the problem!
Simply used this in viewWillAppear method of all my Views, to make it work when started in Landscape mode:
if(([[UIApplication sharedApplication]statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) || ([[UIApplication sharedApplication]statusBarOrientation] == UIInterfaceOrientationLandscapeRight)){
//Landscape View
}
else{
//Portrait View
}
Works fine for me!

Calling dismissModalViewController in UISplitView causes rotate to portrait mode

I am presenting a UIModalView in a UISplitViewApplication. I have wired up a "done" action, which is:
- (IBAction) donePressed:(id) sender
{
[self dismissModalViewControllerAnimated:YES];
}
When I press the button, the orientation of the device changes to potrait mode. Why is this?
I don't think you've provided enough code for anyone to be able to give you an accurate answer, but one possibility is that you haven't implemented the following method in all of your controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
I had this problem and the accepted solution didn't solve it for me.
I was trying to load a modal view controller from a UIPopoverController, and every time it was dismissed it would rotate to portrait.
When I moved the modal view to load from the Detail View Controller of the UISplitView it worked fine.