IOS present modally animation issue - ios7

I am using the present model segue for load the next view controller. It is working fine. Now I am using some conditions. After that it is giving wrong animation.
Method 1
- (IBAction)loginClick:(id)sender {
[self performSegueWithIdentifier:#"mainPageView" sender:self.view];
}
according to this method it is giving correct animation. IOS 7 and IOS 8
After that I am using simple condition
Method 2
- (IBAction)loginClick:(id)sender {
if (self.txtUsername.text.length != 0) {
[self performSegueWithIdentifier:#"mainPageView" sender:self.view];
}
}
According to this method IOS 7 is working fine. But IOS 8 it is moving the next view controller. But animation is not working properly. It is showing more rotation and not regular method.
I am totally confused for this. Anyone have any idea?

In myself I found the solution for this problem. I am using the autolayout and some constraint. In my case that is the issue. I delete the constraint. Now it is working. But still I am confuse. Anyhow it is working

Related

UIImagePickerController is not presenting correctly in iOS 8

I'd like to present an UIImagePickerController with the following code:
self.pickerController = [[UIImagePickerController alloc] init];
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.pickerController.delegate = self;
[self presentViewController:self.pickerController animated:YES completion:nil];
It's working fine for iOS 7 and below, but in iOS 8 I got the following glitch:
While transitioning to the image picker controller (vertical cover animation), the background colour of the picker controller is invisible, revealing the presenting view controller beneath. After transition is finished, the picker's table view will be displayed abruptly without animation.
Sometimes, the picker's table view is not displayed at all, and instead I got a blank black screen. The navigation bar is still there, but no bar button items whatsoever, so user has to force quit the application.
Anyone know what's going on here?
So I managed to find the cause and fix for these problems and want to document it here:
The first problem occurred when I tried to compile to iOS 8 device from XCode 5.1. I switched to XCode 6 beta 2 and now it's working just fine.
The second problem occurred when I tried to reuse an UIImagePickerController that has been displayed before. Create a new instance instead before displaying, and it would be fixed.
Cheers.

Autorotation in ios 5 vs. ios 6 issues

I have an iPad app that must support iOS 5.0 and later. I have a bug that behaves differently in 5.0/5.1 than it does in 6.0. The issue is a view controller in a tabbarcontroller that pushes a modal view, which in turn pushes a full-screen view via navigationController. The problem is, when in the full-screen view, if the iPad is rotated, the underlying viewcontroller (one in the tabbarcontroller) doesn't rotate. Now let me break down the differences in iOS versions:
First of all, this viewController in question implements shouldAutoRotateToInterfaceOrientation (returns YES) as well as willRotateToInterfaceOrientation and willAnimateRotationToInterfaceOrientation.
In iOS 6.0, I noticed that the rotation methods (willRotate... & willAnimate...) were not being called, so I registered it to receive the UIDeviceOrientationDidChangeNotification notification and execute the code from the two Rotate methods if I received that notification and the other methods hadn't executed. That fixed the issue in iOS 6.0.
Problem is, in 5.0/5.1 the rotation methods (willRotate... & willAnimate...) ARE being executed, but the view is not rotating. If the "full-screen view" is not presented over top of this view controller and the iPad is rotated, these two methods execute and the views rotate accordingly.
Please help. Thanks in advance.
Things I've tried other than that stated above.
I've tried checking the UIDeviceOrientation and converting it to a UIInterfaceOrientation and calling [self shouldAutorotateToInterfaceOrientation:xxx]; The view still displays wrong.
When the two rotation methods are being executed, do the CAAffineTransformation for your view. when you are back to normal, again do the same with -90 degree.
https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html

Landscape xib for ipad version only

I have a universal app with seperate xibs for iPhone and iPad
For the iPad version, I want my one of my iPad xibs in landscape mode. I have set it to landscape in simulated metrics, (The app is set for portrait in the summary screen) and the landscape view still shows in portrait when run. Im sure I read on here a naming convention that tells the app the xib is in landscape ie: view1_one.xib~ipad-landscape
Ive tried using screen rotation methods but iOS 6 screen rotation is just proving so frustrating as I have tried so many solutions all of which have no effect. I have done screen rotation before in iOS 6 but I was using storyboards and subclassed a navigation controller for my chosen view, I dont know how to do this with this code as I picked it ip from someone else
So to sum up: How can I get my screen to respect the landscape xib I have created in interface builder instead of showing it in portrait
I would point out I have searched on here for a solution and spent many hours on this before posting this
There are naming conventions for resources (including xib's) that specify on which device type they are loaded. However, these do not exist for specific orientations. -landscape won't do anything extra (more specifically, it will probably load the resource on an iPhone as well, which isn't what you want).
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html#//apple_ref/doc/uid/10000051i-CH1-SW2
As for handling orientation changes, make sure you implement both the iOS 5 and below methods and the iOS 6 methods for handling them:
// Older versions of iOS (deprecated)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
// iOS6
- (BOOL)shouldAutorotate {
return YES;
}
// iOS6
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
// Added after comment
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
This is the official way to ensure that your viewController is only loaded in landscape.
Edit:
I added the preferredInterfaceOrientationForPresentation method as well. While personally I don't like this method, it forces the viewController to present in that orientation, until the next orientation change. Not nice, but it will help you to see if your orientation methods get called at all.
Also try to set a breakpoint in each of these methods. If they don't get called at all, your issue might be with the subclassing. Be certain that the viewController in the storyboard is set to the subclass and not the superclass.
Edit2:
Check this in Interface Builder:

UIBarButtonItem sent action works on iOS 6 but not iOS 5

I am going to tear my hair out because I cannot think of a logical reason why this occurs on 5 but not 6. So basically, I have a view presented in modal fashion with a navigation bar and a Cancel button (UIBarButtonItem - no custom anything on it, just a standard button) in the navigation bar. When this Cancel button is tapped, I want the modal view to disappear. This works just fine in iOS 6. But for iOS 5 it refuses to work for 2 out of 3 places I have it in my code. What's odd to me is that it works on one but not the other two.
Using storyboards, I right click the button, click on "selector" under Sent Actions, and drag over to the appropriate IBAction method in my view controller's .h file. The link is successfully confirmed with the little blinking animation in Xcode. When I run the app on iOS 6 (simulator or device doesn't matter), the method is successfully executed upon button tap and my modal view dismissed. However, on iOS 5, the method is never even called (I set breakpoints inside the method to see if they would be hit). I've even tried switching the argument in my IBAction method from id to UIBarButtonItem *. No cigar, though.
I've also tried programmatically (in viewDidLoad) setting the cancel button's action to a selector. I've even set the target to the VC. No cigar again. Here is a screenshots of my current setup:
Please note the IBAction methods.
Is there some magical clause in the documentation that I missed? Something awfully special I need to do in order to get it to work in iOS 5? It sure seems like a bug to me, but I'm still fairly new to this stuff so what do I know.
I am using Xcode 4.5.2 and storyboards, and targeting iOS 5 and iOS 6 for the release.
Your help is appreciated, thank you.
I think there may be problem of using GestureRecognizer please comment that code and try it...
I added a separate UIView that resides under my textfields and button and below the navigation bar/title. I added the tap gesture to that programmatically, and that seems to recognize both my tap and the cancel button's action. I still would like to know why the tap gesture swallows up the UIBarButtonItem's action if the gesture is on the root view. This question helped me figure this out. Thanks.
you can exclude view/control from gesture recognizer using following delegate method.
// UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// exclude your view from gesture recognizer
if(yourView == touch.view)
{
return NO;
}
//
return YES;
}

Passcode view on top of everything when app is back from background, and supports autorotation

I have a simple UITabBarController-based universal app that I'm adding autorotation support on iPad, and the only thing that's giving me headaches at the moment is supporting autorotation for the PassCode view controller (XIB-based).
Requirements:
1- Passcode VC's view to be presented with autorotation support at the app launch (Done).
2- Passcode VC's view to be presented with autorotation support when the app is back from background (didBecomeActive:), and to be on top of everything else.
What I tried for requirement #2:
1- Adding the Passcode's view as a subview to the app's window (addsubview:). Works great except that autorotation doesn't work (I understand why).
2- Adding the Passcode's view as a subview to the tabbar controller's view (addsubview:). Autorotation works great, but if another view controller is being presented modally, the Passcode's view will be underneath it for sure (Also understandable).
I can see other apps implementing the exact same thing I want, like DropBox and GoodReader for example.
Any input is pretty appreciated!
Thanks in advance.
I can't tell you this is the best way, but we managed to get similar functionality using a separate window. We started out using this library: Block Alerts which was a pretty good jumping off point.
This got us our new UIWindow that would appear on top of everything, but didn't auto-rotate very well. However, with a little experimentation, we found that the following would give us the auto rotation that we desired:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
CGPoint newCenter = CGPointMake(kDefaultPortraitWidth / 2, (kDefaultPortraitHeight * 0.3f));
containerView.center = newCenter;
}
else
{
CGPoint newCenter = CGPointMake(kDefaultPortraitHeight / 2, (kDefaultPortraitWidth * 0.2f));
containerView.center = newCenter;
}
return YES;
}
The container view just contained all of our 'stuff' to make it easier to move around like this.
Note: the constants aren't really important, use whatever makes your view work.