I'm reading the html file into the UIWebview
. In the webViewDidFinishLoad
I'm doing javascript function for horizontal scroll. Below code works fine. But i cant predict when javascript function finish.
in the visible webview first load the html file then script run. so i can determinate javascript finishing in the webViewDidFinishLoad
.
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *scriptString =@"javascript:function initialize() { var eelam = document.getElementsByTagName('body')[0]; var ourH = window.innerHeight;var ourW = window.innerWidth; var fullH = eelam.offsetHeight; var pageCount = Math.ceil(fullH/ourH)+1; var padval = parseInt((screen.width*10)/100);var currentPage = 0; var newW = pageCount*ourW;eelam.style.height = (ourH - 30)+'px';eelam.style.width = (newW)+'px';eelam.style.webkitColumnGap = '5px'; eelam.style.margin = '25px'; eelam.style['margin-left']='2px';eelam.style.webkitColumnCount = pageCount; window.interface.setPageCount(pageCount);window.interface.setColumnWidth(screen.width);window.interface.setContent(eelam);window.interface.setColumnGap(padval);};";
// set font
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'",
textFontSize];
[mywebview stringByEvaluatingJavaScriptFromString:scriptString];
[mywebview stringByEvaluatingJavaScriptFromString:@"javascript:initialize()"];
[mywebview stringByEvaluatingJavaScriptFromString:jsString];
// scroll disable
UIView* row = nil;
for(row in webView.subviews){
if([row isKindOfClass:[UIScrollView class] ]){
UIScrollView* scrollRow = (UIScrollView*) row;
scrollRow.scrollEnabled = NO;
scrollRow.bounces = NO;
scrollRow.pagingEnabled=YES;
}
}
// this code is also not use to handle my issue
if ([[mywebview stringByEvaluatingJavaScriptFromString:@"document.readyState"] isEqualToString:@"complete"]) {
}
}
please advise me,
thanks in advance,