UIWebView’s weird PDF display bug on the iPad
UIWebView seems to have a weird display bug connected to PDFs and interface rotation in iPhone SDK 3.2. This is how a PDF displayed in a UIWebView looks on the iPad after you rotate the device from portrait to landscape:
The PDF appears to be split in half vertically along an edge that was right in the middle of the page while the device was in portrait orientation. The right half is vertically offset from the left half. Other people have also noticed it so I believe it is a genuine bug.
To reproduce it, try the following:
- Create a UIWebView and set
scalesPageToFit = YES. - Embed the web view in a view controller that supports both portrait and landscape orientation.
- Load a PDF file into the web view.
- Rotate the iPad from portrait to landscape or vice versa.
Or download the sample project I have created.
I can reproduce this consistently with a number of different PDF files using iPhone SDK 3.2 both in the iPad Simulator and on an actual iPad. The bug does not appear with HTML content nor is it present on the iPhone. It also disappears if you zoom into the page just a little bit or if you set scalesPageToFit = NO.
Workaround: Reload the document after rotation
The only workaround I have found so far is to reload the document after the device has been rotated. It is not very pretty because reloading can take some time and the user can still see the buggy display for a second, but other than that it works. The best place for the reloading code seems to be your view controller’s -didRotateFromInterfaceOrientation: method.
Reported to Apple as Radar #8065859.
Update June 12, 2010: Apple has confirmed this bug as a duplicate to #7790957.

Observing the same problem but it also occurs if you programmatically change the size of the UIWebView.
Leon Stankowski
16 Jun 10 at 11:39 pm
Thanks for the workaround, it’ll do for now but hopefully Apple will sort it out soon.
Geoff Hill
18 Jun 10 at 7:32 am
just hit this.
Thanks for pointing this out.
ahlongxp
1 Jul 10 at 9:03 am
Got the same — reported
Dominik
1 Jul 10 at 12:18 pm
tried for hours.
its really only reload that seems to work
Dominik
1 Jul 10 at 2:12 pm
I download sample code but it has still bug with rotation.
jjan
6 Jul 10 at 5:23 am
@jian: Sure. The sample project is there to illustrate the bug.
Ole Begemann
6 Jul 10 at 1:44 pm
Can you explain what the fix is? How do you reload ?
blade
7 Jul 10 at 5:47 am
@blade: Just call -[UIWebView reload].
Ole Begemann
7 Jul 10 at 11:47 am
I was hit by this too, thanks for the workaround even though it’s a nasty one.
Mike
19 Jul 10 at 10:51 am