0

I have an app with some views, I need one view to rotate. that view is called by pushviewcontroller. all these views are inside a tabbarcontroller.

I already edit the info.plist to support orientations I added this items to Supported interface orientations: Landscape (left home button) Landscape (right home button)

and also added this to the view i want to rotate

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return YES;    
}

but it doesnt work.

what do i need to do? Thanks

atrik
  • 1
  • 2

1 Answers1

0

UITabBarController have a some problem. the problems is a subviews(selected index) not autorotate.

So, you can make a category, and add a below code.

and, add a #import "UITabBarController+Autorotate.h"

#import <Foundation/Foundation.h>


@interface UITabBarController (Autorotate)

@end

#import "UITabBarController+Autorotate.h"


@implementation UITabBarController (Autorotate)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    UIViewController *controller = self.selectedViewController;
    if ([controller isKindOfClass:[UINavigationController class]])
        controller = [(UINavigationController *)controller visibleViewController];
    return [controller shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end
bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
  • but from the tabbar I load a view and from that view I push the view that I want to rotate. where should I put that code ? thanks by the way my tabbarconroller is in my delegate – atrik Oct 10 '11 at 17:31
  • File-New-New File- [Objective-C category] create You can make a category. and add a code. and in your view add a #import and normally use a shouldAutorotate Method. – bitmapdata.com Oct 10 '11 at 17:35
  • Thanks!!! it works. just one more question, I have load an image from internet but when the iPhone is in landscape how can I resize it or call another view thanks – atrik Oct 10 '11 at 17:52
  • using this method. refer a apple reference. http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html – bitmapdata.com Oct 10 '11 at 17:58
  • can you help me with something else, when i am in the pushedview and I return to the view that pushed it it mantains the landscape mode ! how do i force it to return to portrait ? thanks – atrik Oct 10 '11 at 18:01
  • refer a this link. maybe your issue same. http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation – bitmapdata.com Oct 10 '11 at 18:09