0

I am writing a language translation iPad app. The aim is to divide the screen in two horizontal sections. The upper section will display an article in English, while the lower section will display the translated the article in Chinese. I need to achieve the following:

  1. Upon clicking a text in the upper frame, its translation in the lower frame should get highlighted.

  2. The two sections should scroll synchronously

I am using local HTML pages with UIWebview.

Q1. If I use one UIWebview with two frames, I cannot achieve individual scrolling (i.e, the the entire page with both frames scrolls as one set). Is there a way to achieve individual scrolling?

Q2. If I use two UIWebViews, how can I trap a DOM event from one UIWebView and send it to another UIWebView?

Q3. Any better approaches to achieve the same?

Thanks in advance.

Amarsh
  • 11,214
  • 18
  • 53
  • 78
  • See this post: http://stackoverflow.com/questions/3272089/programmatically-selecting-text-in-an-input-field-on-ios-devices-mobile-safari – Mick MacCallum Aug 11 '12 at 20:27

1 Answers1

0

Using two UIWebViews with JavaScript on either of them works. Intercepting the clicks by using JS span/window.location in source UIWebview and invoking JS in target UIWebView in - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType through [targetWebView stringByEvaluatingJavaScriptFromString:jsCommand];

Amarsh
  • 11,214
  • 18
  • 53
  • 78