我试图弄清楚如何解决仅在iOS 4.3上出现的错误。启动应用程序时,它将显示缩放为适合UIWebView的PDF。直到您捏放大文档,然后旋转文档,然后在黑色区域后方,它的表现都非常完美。如果您不捏变焦,它不会离开黑色区域。我不明白为什么这是仅iOS 4.3的问题。
问题的屏幕截图:我一直在尝试解决这一问题,非常感谢您的帮助。谢谢。
.xib设置的屏幕截图:
我使用的代码是:
。H:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
UIWebView *webView;
}
@property (nonatomic) IBOutlet UIWebView *webView;
@end
.m:
#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
最佳答案
我记得过去有一些关于UIWebView和旋转的错误。我特别记得还存在一些渲染和调整大小的问题。老实说,如果它从iOS 4.3开始就起作用了,那么我认为您甚至不应该去尝试解决此问题-在这一点上,很可能您提出的解决方案是很棘手且无关紧要的。
话虽如此,this thread可能会帮助您解决问题。
关于iphone - UIWebView自动调整大小问题仅在iOS 4.3上,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12869291/