简体   繁体   中英

Control UIWebView from the web page

How can I control the UIWebView in an iOS app from the web page?

For example, I want to resize it - not by setting the UIWebView's frame (in the Objective C code), but with some Javascript code, like window.resizeTo()

I've heard that I should implement a class that enables external control on the UIWebView. Does anyone know which class is it?

Thanks, Keren

Check out lines 26-45 in this class.

https://github.com/trailbehind/Map-Chat/blob/master/Classes/ChatViewController.m

Is that what you are looking for?

I was using a UIWebView within a chat app. You can basically make a UIWebView do any JavaScript you want.

Two things you can look at:

  • the UIWebView method stringByEvaluatingJavaScriptFromString

  • the UIWebView Delegate Protocol Reference, especially the webView:shouldStartLoadWithRequest method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM