uiwebview

How can I reliably detect a link click in UIWebView?

强颜欢笑 提交于 2019-11-29 04:12:54
I have a UIWebView and I need to do something when user taps a link. There’s a delegate callback that can be used to detect the taps: - (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request navigationType: (UIWebViewNavigationType) navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked) { … } } The problem is that this code doesn’t handle all link clicks. As an example, a plain Google Search results page does something weird with the links: <a href="http://example.com/" class="l" onmousedown="return rwt(…)"> <em>Link Text</em> </a> The rwt

How to get the url of currently playing video in UIWebview

三世轮回 提交于 2019-11-29 04:06:06
问题 Is there any way to get the link of currently playing video.I am loading m.youtube.com .For some videos it is not even entering the delegates.I tried using a NStimer as well.But for some videos it is not the clicked url 回答1: There is a hacky way of doing it by listening for the AVPlayerItemBecameCurrentNotification notification. This notification is fired when a UIWebView shows the media player, and it sends an AVPlayerItem as the notification's object. For example: [[NSNotificationCenter

How to get the content height of a UIWebView in iPhone sdk, objective-c? [duplicate]

巧了我就是萌 提交于 2019-11-29 04:01:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to determine the content size of a UIWebView? Hai Guys, I got a problem while lodaing the htmlString into UIWebView, I have set the frame height of a webview in iphone is 265 always. webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 41, 320, 265)]; Is there any property to get content height of a UIWebView. If I got the content only one or two lines then it is looking odd below the two lines. How can

Javascript core crash when using YouTube iframe player in UIWebView in iOS 11.3

两盒软妹~` 提交于 2019-11-29 03:56:38
问题 We have an iOS app with a UIWebView that loads YouTube iframe player to play youtube videos. After iOS 11.3 released we found that there are a lot of javascript core crashes. On Fabric crashlytics the crash stcktrace looks like this Crashed: WebThread 0 JavaScriptCore 0x18aa48298 JSC::JSLock::DropAllLocks::DropAllLocks(JSC::VM&) + 176 1 JavaScriptCore 0x18aa4826c JSC::JSLock::DropAllLocks::DropAllLocks(JSC::VM&) + 132 2 WebCore 0x18b78b794 SendDelegateMessage(NSInvocation*) + 360 3

Submit a form in UIWebView

风流意气都作罢 提交于 2019-11-29 03:05:33
问题 I have a form in the UIWebView to interact with a web service, when I submit the form, the data gets sent to a web service and it will return the result to another UIWebView. The two UIWebViews are under a navigation controller, so when the use submits the form, it slides to another view to display the result. Can anyone point me out how I can achieve this? What do I fill in the "action" attribute in the form element? How can I get the user input back to the application so I can use the web

Add a UITapGestureRecognizer to a UIWebView

时光怂恿深爱的人放手 提交于 2019-11-29 02:59:10
In iOS, is it possible to put a tap recognizer on a UIWebView, so that when someone single-taps the web view, an action gets performed? Code below doesn't seem fire handleTap when I tap my webView. Thanks. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)]; tap.numberOfTapsRequired = 1; [webView addGestureRecognizer:tap]; [tap release]; -(void) handleTap { NSLog(@"tap"); } I found that I had to implement this method to get it to work: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer

How to detect and handle HTTP error codes in UIWebView?

喜你入骨 提交于 2019-11-29 02:51:11
问题 I want to inform user when HTTP error 404 etc is received. How can I detect that? I've already tried to implement - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error but it is not called when I receive 404 error. 回答1: You could capture the URLRequest here: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType and hand the request over to the delegate and return no. Then in the

Media Callbacks with Embedded YouTube Videos on iOS

烈酒焚心 提交于 2019-11-29 02:46:51
I’m embedding YouTube videos in a UIWebView for an iOS app. I’m using “Method 2” at this YouTube blog post to embed the video. This works great, except that because iOS manages the media player, I can’t determine whether the video is playing or is done. I don’t want to swap that view out with another one while the video is playing, but I don’t see a good way to determine that. Any ideas? If there’s a way to get a JavaScript callback, that will work, or if there’s a way to embed YouTube videos using the HTML5 <video> tag, that will work as well (I’ve tried that and not gotten success). you can

UIWebview gets stuck with the following message in console

无人久伴 提交于 2019-11-29 02:29:31
问题 UIWebview gets stuck with the following message in console. void SendDelegateMessage(NSInvocation*): delegate (webView:didFinishLoadForFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode anyone knows what this is?? 回答1: Are you using any Javascript on the page you are loading? Specifically, are you using the method - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script As the docs state the following JavaScript execution time is

Has anyone found that UIWebView fails for some URLS?

谁都会走 提交于 2019-11-29 02:26:02
问题 I have been working on an iPhone App for a couple of weeks now and one of the earlier features I added was a UIWebView that loaded context sensitive Wikipedia page topics. This was pretty trivial to implement and has been working fine for some time. Today, I found that functionality had unexpectedly stopped working. I had been fiddling around at the perimeter of that piece of code and initially assumed that I had broken something. I checked all the obvious places, my urls, was the UIWebView