UIWebView autosize issue only on iOS 4.3

Posted by troop231 on Stack Overflow See other posts from Stack Overflow or by troop231
Published on 2012-10-13T01:58:46Z Indexed on 2012/10/13 3:37 UTC
Read the original article Hit count: 209

Filed under:
|
|
|
|

I am trying to figure out how to fix this bug that only occurs on iOS 4.3. When the application launches, it displays a PDF that is scaled to fit in the UIWebView. It behaves perfectly until you pinch to zoom on the document, and then rotate it, leaving behind a black area. If you don't pinch to zoom, it doesn't leave the black area. I don't understand why this is a iOS 4.3 only issue. Screenshot of the issue: I've been trying to solve this problem awhile now, and would greatly appreciate your help. Thank you.

enter image description here

Screenshots of the .xib settings:

enter image description here enter image description here enter image description here

The code I'm using is:

.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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c