UIWebview flickering issue

Hi folks,

while very recently working in one of my apps, I encountered a strange issue with UIWebview. Well it’s something like this, a single view application where I was trying to load some jQuery demos from the jQuery site on my UIWebview, I found it does flickers every now and then when I click on a component from the demos and it was occurring only in Portrait orientation.

After tinkering many hours, finally fixed the issue which was something to do with CSS in webkit. The fix I’m going to write it down:

step1: add a CSS file to your XCode project directory

.ui-page {

-webkit-backface-visibility: hidden;

}

step2: evaluate the JS out of it and add it to the DOM before the page load events

OR

You can use it directly as a parameter to stringByEvaluatingJavaScriptFromString method of Objective C on your UIWebView object. See it below:

[yourUIWebviewObject stringByEvaluatingJavaScriptFromString:

@”$(document).ready(function(){”

“$(‘head’).append(‘<style>.ui-page {”

“-webkit-backface-visibility: hidden;”

“}</style>’)”

“});”

]

Hope it will help out there someone.

cheers 🙂


About this entry