UIwebView links delay
I have a UIWebView with some links in it. When I click the link, there's a delay of about 2-3 seconds before the link is loaded. Is this how it's suppose to be or is there a 开发者_运维问答setting I can change? Thanks.
In iOS5 the UIScrollView
belonging to a UIWebView
has been exposed so that you can change its behavior. So to remove the click delays you can simply do:
[webView.scrollView setDelaysContentTouches:NO]
This way you don't have to use any javascript libraries to remove the delay.
As a bonus, you can make the scrolling in a UIWebView
feel a bit more native by changing the decelerationRate:
[webView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal]
If you mean that after clicking the link there is a delay before the the link is highlighted, this has to do with how the touches are handled by the UIWebView. I doubt that this can account for the whole 2-3 secs delay, but anyway refer to this post to remove it.
If you mean that after clicking on a link it takes 2-3 seconds until you can see the page rendered, then it is (unfortunately) normal. UIWebView
is known for being slow at rendering even a simple page.
Check if you are calling the load method on main thread or not. If you are testing it on Simulator then calling a method on secondary thread takes some time to execute rather than crashing or throwing an exception. Replace such call (if any) by performSelectorOnMainThread
method.
精彩评论