Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

troop231

macrumors 603
Original poster
Jan 20, 2010
5,826
561
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:

QEDrz.png


Screenshots of the .xib settings:

BkIWQ.png
T46iT.png
8i8y2.png


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:
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?
 
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.
 
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?
 
Dunno.

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

Do you set the Window's rootViewController?
 
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.
 
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?
 
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:

OAdAf.png
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.