I didn't add any Transition animation on Back Button.
My Code is really simple like below,
categorySubListViewController *categorySub =[[categorySubListViewController alloc] initWithNibName:#"categorySubListViewController" bundle:nil];
categorySub.detailViewController=self.detailViewController;
[self.navigationController pushViewController:categorySub animated:YES];
However , popview controller animation is wrong and it showing like below (up to down animation) .
It should be right to left animation .
Is there any wrong in my code or iOS 6 problem ?
Working well on iPhone iOS 6 , iPad iOS 6 Portrait.
fixed.
The problem is
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
It should be
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
Related
I am seeing an issue that only happens on IOS 7 and not IOS 6, i.e. the same code works on 6 but not 7.
Basically, there is this view that I need to transition to that must be in portrait mode.
So, like many of the other examples I found on StackOverflow, the way to force an orientation would be to call this on the navigation controller :
UIViewController *mvc = [[UIViewController alloc] init];
[self presentViewController:mvc animated:NO completion:^{
[self dismissViewControllerAnimated:YES completion:^{
NSLog(#"Cleared");
[mvc.view removeFromSuperview];
[mvc removeFromParentViewController];
}];
}];
And in the target controller, I have:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotate
{
return NO;
}
However, once I transition to this target UIViewController, nothing on that UIViewController becomes tappable at all. I am very sure that the UIButtons are linked properly because if I just load up this controller as the first controller when the app starts, the buttons all worked fine, but if I have to force an orientation on it before showing it, then the buttons don't work
I was wondering if anyone else has encountered such an issue in IOS 7 as well? This works perfectly in IOS 6
Thanks
IS
I have an app where landscape left and landscape right are both enabled in the build settings, but I'd only like these to be available in one ViewController in the app.
I'm using a navigation controller, and in the first ViewController I push onto the stack, I'd like to disable rotation altogether. I've tried all 3 of these with no success:
- (BOOL)shouldAutoRotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}
When I rotate the device in the simulator, the layout still changes. I know the last method is deprecated in iOS 6.
Any ideas?
Fixed it. The reason was because the navigation controller was being rotated, and this was not triggering - (BOOL)shouldAutorotate to be called in the top view controller, as I thought it would.
I subclassed the navigation controller and added
- (BOOL)shouldAutorotate {
return NO;
}
I am using IASK in my app, and I just found a problem. That is when I'm going to change my device orientation, and the main viewcontroller is working well (both iOS 5 & 6). But in the IASK view controller it doesn't work! In addition, the viewcontroller always splash flips the view when I press the settings button to get into the IASK view controller. I am trying to figure out what's wrong in my code. I did add both view orientation methods for iOS 5 & 6 into IASK view controller as well, but it still doesn't perform correctly.
Does anyone know how to solve this kind of problem?
//ios5 autorotate
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) {
return YES;
}
else return NO;
}
//ios6 autorotate
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (BOOL)shouldAutorotate
{
return YES;
}
I'am currently working on an project where we have a tab bar controller with 4 tabs, and where each tab have an navigation controller. On each of these navigation controller there is multiple viewcontrollers pushed on it.
I read a lot of post here and other places, and we have currently done the following:
Subclassed UITabbarcontroller
- (BOOL)shouldAutorotate
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotate];
}
- (NSUInteger) supportedInterfaceOrientations
{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController]supportedInterfaceOrientations];
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
This work fine, if we in each of our viewcontrollers specify the following:
- (NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
This will lock it to Portrait as expected.
But now the real problem occurs!
If we in our viewcontroller on one of the tabs specify that it should rotate to landscape it works fine, but when we then change tab it is still in landscape, which is not what we want!
So to sum up, have anyone got a solution to how you lock almost all views to a given orientation expect one, and can change tabs where they are in the orientation you specified (here portrait)?
I also read this post iOS 6 UITabBarController supported orientation with current UINavigation controller, but as one comment also mentioned "This is almost working for me. The problem is if I am already in landscape when I switch tabs to a portrait only view it is still in landscape. Rotating portrait fixes it and it won't rotate back to landscape, but I still need it be in portrait when it first loads" which almost is the same here..
I myself had this problem and i worked out a solution, its not pretty but it works.
In your TabbarController subclass implement this tabbarcontroller delegate function (remember to set delegate):
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
int selected = self.selectedIndex;
UIViewController *con = [[UIViewController alloc] initWithNibName:#"XIBName" bundle:nil];
[[self.viewControllers objectAtIndex:selected] pushViewController:con animated:NO];
[[self.viewControllers objectAtIndex:selected]popViewControllerAnimated:NO];
[[self.viewControllers objectAtIndex:selected] setDelegate:nil];
}
The push and pop on the uinavigationcontroller in the tabs navigationcontroller will make the tabbarcontroller fire its Orientations functions again, and if you implemented the orientations code correctly it will change to your desired orientation.
i hope this helps, please fell free to comment if i need to explain anything in details.
Best Regards
Morten
I have an application which normally is a portrait app and only show landscape view for one UIViewController. It works fine until the new iOS 6 is released.
I really don't understand how orientation works in iOS 6. So I wrote a testing app. Here is what I did:
Set the orientation of the application to support all orientations.
I'm using story board. The rootViewController is embedded in UINavigationController which is in portrait.
The code in rootViewController:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
When I clicked the Open bar button, I'll push another (SecondViewController) view controller which supposed to be in landscape mode:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
Although this method is called correctly, the second view controller is always also in portrait mode.
Can anybody give me some suggestions? Thanks
Here is my solution:
In second view controller's viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
UIViewController *viewController = [[UIViewController alloc] init];
[self presentViewController:viewController animated:NO completion:^{
[viewController dismissViewControllerAnimated:NO completion:nil];
}];
}
This will force the second view to rotate to landscape orientation which solved my problem. And it works for iOS 5 and 6.
For iOS-6, I have done this. It is running fine
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeLeft;}
In second View
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return YES;}
I think that best solution is to stick to official apple documentation. So according to that I use following methods and everything is working very well on iOS 5 and 6.
In all of your ViewControllers override following methods.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Methods for iOS 6, first method returns supported orientation mask (as their name indicate), you can change it into Landscape or what suites you best.
-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait; //UIInterfaceOrientationMaskPortrait or LandscapeLeft ...
}
second one thats tells your VC which is preferred interface orientation when VC is going to be displayed.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait; //tells your VC in which orientation it should be presented, if you set Porttrait it would be in Portrait or otherwise ...
}
This solution is working smooth, I dont like the idea of creating macros and other stuffs, that goes around this simple solution.
Hope this help...