UIWebView: things you can’t do
UIWebView is a really useful component, but there are a few things that it does not allow you to do easily (you can google for work-arounds to most of these, but they are often convoluted or imperfect):
- you cannot easily prevent UIWebViews from scrolling horizontally, even if the content should fit
you cannot easily tell a UIWebView to scroll to a particular point (the workaround involves using javascript to scrollTo certain content)(note: in iOS5 this may be fixed by the fact that you now have direct access to the scrollView of a UIWebView)- you cannot detect taps within a UIWebView - even a UITapGestureRecognizer attatched to a UIWebView is going to fail. (there are many ways to workaround this, including a custom UIWindow that traps all taps at a higher level and then passes them on, or javascript functions that you can add to the content that calls back to your application code)
Other interesting things to note:
- every application has its own cookie store for UIWebView. So users who browse to a website within your app will not have the same cookies as when they use Safari itself
- the shadows on the edges of a UIWebView (when you scroll past the page) can be hidden, and often looks best if you do (it involves accessing subviews of the UIWebView… finicky but not a private API)
- UIWebViews can be made transparent. Set the document background color in your HTML to transparent and tell the UIWebView isOpaque:NO
Anyway, those are just some of my notes on UIWebView. It is a really powerful component, but sometimes doesn’t work the way I would expect.
If you have any corrections, feedback or questions, feel free to let me know (contact details in the bar on the right).