iPhone Hacking
After much experimentation, I got UIWebView to work on the iPhone. I’m running with what is probably an old devkit at this point, but after a lot of playing around, I edited the UIKit/UIWebView.h file to remove the bits that kept it from compiling. I later found this diff which more or less is exactly what I ended up doing.
After the UIWebView header was fixed up, I played around a bit and ended up with some very simple code that puts a UIWebView inside of a UIScroller which results in a webview that has the ability to pan around the page. I did find that playing with setEnabledGestures: on the webview itself allowed me to get pinch-zoom to work, I’m being lazy since I don’t think I need it for this particular project that I’m working on and it didn’t work quite the way I wanted it to anyway.
I posted the files to my iApp-a-Day source repository on Google.
Oh.. I haven’t mentioned iApp-a-Day, you say? Well, I’m still not sure it’s possible… but if all goes according to plan, I’ll be trying to publish one iPhone app for each day in November. It should be interesting, anyway… It was Jer’s idea and I might get some help from temas - but so far it’s just been me. I’m getting a bit nervous about it all because it’s the 20th now and I only really have two apps ready in the queue… November has 30 days! I guess we’ll see what happens…
November 7th, 2007 at 10:56 am
Nice work! Are you on app #7 today? Drop me a line some time. -coolblade
November 7th, 2007 at 6:48 pm
hey can you publish all the files needed to make this compile? Having trouble integrating the scroller into the uiapplication. Thanks man!
November 7th, 2007 at 7:15 pm
@coolblade: Check out the source for Melt: http://iappaday.googlecode.com/svn/trunk/Melt/ - it uses the UIWebView. It might have a scrolling bug on 1.1.1, though, which I’ve figured out in Burp - but I haven’t published Burp’s code just yet.
November 8th, 2007 at 9:47 am
Sean, thank you so much!
November 26th, 2007 at 4:22 pm
Can you describe the fix in the Burp code? I’m using a UIWebView and in 1.1.1 it stopped adjusting for content size changes it seems, and I don’t even get didSetFrame called on my object.
November 26th, 2007 at 4:24 pm
@Max: Not sure if you’ve seen this, but the code is all online. Here’s the main UIWebView stuff from Burp: http://iappaday.googlecode.com/svn/trunk/Burp/SimpleWebView.m
November 27th, 2007 at 5:41 am
Thanks, I found the code. Can’t get it to work for me though, the content size still stays static. Going to try to go back to first principles and see if I can figure it out. didSetFrame and didDrawInRect don’t even get called on my object.
November 27th, 2007 at 10:03 am
All of the sudden it’s started working, not sure which change did it, but I guess I’ll just act like none of this ever happened. Thanks for the info!