0

我有一个加载 html 的简单 UIWebView 应用程序,问题是当我旋转设备时 UIWebView 不旋转。

这是 ViewController.m

#import "WrapperViewController.h"

@implementation WrapperViewController

- (void) viewDidLoad
{
    NSBundle *bundle   = [NSBundle mainBundle]; 
    NSString *path     = [bundle bundlePath];
    NSString *fullPath = [NSBundle pathForResource:@"index"
                         ofType:@"htm" inDirectory:path];

    [webView loadRequest:[NSURLRequest requestWithURL:
                         [NSURL fileURLWithPath:fullPath]]];

}

- (BOOL) shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{

    return YES;
}

-(BOOL)shouldAutorotate{
    return YES;
}


- (void) didRotateFromInterfaceOrientation:
  (UIInterfaceOrientation)fromInterfaceOrientation
{
   webView.scalesPageToFit = YES;
   webView.backgroundColor = [UIColor blackColor];

}

- (void) didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void) dealloc
{
    [super dealloc];
}

@end
4

0 回答 0