iPhone rotation won't rotate UIWebView

我的未来我决定 提交于 2020-03-05 02:25:10

问题


My view hierarchy looks like this:

tab bar -> navigation bar -> table view -> view 1 -> view 2 (UIWebView)

How can I rotate view 2 so it can be displayed in both landscape & portrait mode?


回答1:


Heres your fix...just solved the same problem. The issue is the tab bar controller is responding no to the shouldRotate method.

Ignore the advice in the apple docs and create a subclass for tab view controller. In that subclass handle the shouldRotate

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Always returning YES means the view will rotate to accomodate any orientation. return YES; }

Heres my complete subclass TSTabBarController.h

#import <Foundation/Foundation.h>
@interface TSTabBarController : UITabBarController {

}

@end

and the implementation file.

#import "TSTabBarController.h"


@implementation TSTabBarController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Always returning YES means the view will rotate to accomodate any orientation.
    return YES;
}


@end

If you change the class in IB for the tab bar controller you should just work.

Hope this helps.
Rich



来源:https://stackoverflow.com/questions/2113748/iphone-rotation-wont-rotate-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!