Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  90] [ 3]  / answers: 1 / hits: 27137  / 14 Years ago, thu, may 20, 2010, 12:00:00

Is there a way to get a callback to objective-c when a certain event has been detected in a UIWebView? Can Javascript send a callback to Objective-C?


More From » objective-c

 Answers
36

Update - don't use UIWebView anymore. Use WKWebView, or better yet (if it fits your needs and you're building for iOS 9), a Safari View Controller.



But if you must use UIWebView, in your UIWebView delegate, provide an implementation for webView:shouldStartLoadWithRequest:navigationType:



In your HTML or Javascript files, add functions that send URLs to a custom scheme (for readability purposes, the custom scheme isn't required). All the URLs sent will be passed to your Objective-C method implementation, and then you can do what you'd like.


[#96728] Tuesday, May 18, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
micah

Total Points: 295
Total Questions: 104
Total Answers: 92

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
micah questions
Mon, Jan 24, 22, 00:00, 2 Years ago
Thu, Dec 31, 20, 00:00, 4 Years ago
Thu, Aug 27, 20, 00:00, 4 Years ago
Wed, Apr 15, 20, 00:00, 4 Years ago
;