2

我试图弄清楚如何修复这个仅在 iOS 4.3 上出现的错误。当应用程序启动时,它会显示一个 PDF,该 PDF 已缩放以适合 UIWebView。它表现完美,直到您捏合以放大文档,然后旋转它,留下黑色区域。如果你不捏缩放,它不会离开黑色区域。我不明白为什么这是一个 iOS 4.3 唯一的问题。问题截图:我一直在尝试解决这个问题,非常感谢您的帮助。谢谢你。

在此处输入图像描述

.xib 设置的屏幕截图:

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

我正在使用的代码是:

。H:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
   UIWebView *webView;
}

@property (nonatomic) IBOutlet UIWebView *webView;

@end

米:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize webView;

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    return YES;
    } else {
    return (interfaceOrientation !=
            UIInterfaceOrientationPortraitUpsideDown);
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];

    NSURL *url = [NSURL fileURLWithPath:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    [webView loadRequest:requestObj];
}

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

@end
4

2 回答 2

1

我记得过去 UIWebView 和旋转存在一些错误。我特别记得有一些渲染和调整大小的问题。老实说,如果它从 iOS 4.3 开始就有效,那么我认为你甚至不应该费心去解决这个问题——你想出的解决方案很可能在这一点上会很老套而且无关紧要。

话虽如此,这个线程可能会帮助您解决问题。

于 2012-10-17T16:20:16.153 回答
0

如果它在 iOS6 中工作,可能是因为 shouldAutorotateToInterfaceOrientation 永远不会在其中被调用。iOS6 改变了处理旋转的方式。它碰巧在您的代码中起作用。

另一种可能的解决方案是使用 webview 的委托等到它被加载然后将其添加到视图中。

于 2012-10-15T04:49:13.817 回答