iOS UIWebView autosize issue only on iOS 4.3

troop231

macrumors 603
Original poster
Jan 20, 2010
5,628
311
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. I've been trying to solve this problem awhile now, and would greatly appreciate your help. Thank you.

Screenshot of the issue:



Screenshots of the .xib settings:



The code I'm using is:

.h:
Code:
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
   UIWebView *webView;
}

@property (nonatomic) IBOutlet UIWebView *webView;

@end
.m:
Code:
#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
 
Last edited:

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Is that black area part of the webview or another view? Does this happen with other pdf files or other content in the web view? Is the webview inside another view?
 

troop231

macrumors 603
Original poster
Jan 20, 2010
5,628
311
Is that black area part of the webview or another view? Does this happen with other pdf files or other content in the web view? Is the webview inside another view?
The black part is part of the webView. It happens with all PDFs and webpages. The webview is inside of the main view in the .xib.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
What is the iOS deployment target for the xib file? It's listed in one of the tabs in the views on the right. Is it possible that it's 5 or greater?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Dunno.

Does your app have a container view controller like a nav controller or tab bar controller?

Do you set the Window's rootViewController?
 

troop231

macrumors 603
Original poster
Jan 20, 2010
5,628
311
Dunno.

Does your app have a container view controller like a nav controller or tab bar controller?

Do you set the Window's rootViewController?
I don't have a nav or tab bar based app. I actually created this app as a single view based application to test and work out the webView resize bug in my real applications. So far I can't fix it.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I recommend that you use a UINavigationController as a container view controller. If you don't want to see the navbar then make it hidden.

Does your real app have a container view controller?
 

troop231

macrumors 603
Original poster
Jan 20, 2010
5,628
311
I recommend that you use a UINavigationController as a container view controller. If you don't want to see the navbar then make it hidden.

Does your real app have a container view controller?
My real app is a navigation based app, and the problem exists there as well on iOS 4.3.

Edit: I just made a quick sample tab bar based app, and the issue/bug is still there:

 
Last edited:

Similar threads

Register on MacRumors! This sidebar will go away, and you'll see fewer ads.