uiwebview

UIWebView respond to Javascript calls

老子叫甜甜 提交于 2019-11-30 10:46:46
How can I intercept Javascript calls such as window.open as Mobile Safari does? I haven't seen anything listed about this, but it must be possible somehow? Has anyone done this before? FKDev When the page is finished loaded (webViewDidFinishLoad:), inject a window.open override. Of course it will not work for window.open which are called during page load. Then use a custom scheme to callback your objective C code. [EDIT] OK I have tested it. Now it works. Create a new "view based" project and add a webview in the viewcontroller xib using IB. @implementation todel2ViewController // Implement

playing a local video in a uiwebview

浪子不回头ぞ 提交于 2019-11-30 10:28:27
i load a local html file into an ipad application: NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; NSString *path = [[NSBundle mainBundle] pathForResource:@"lieferant1" ofType:@"html"]; NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; [webView loadHTMLString:content baseURL:baseURL]; the webpage gets displayed, content of my html file: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore

Scrollable div on iPhone without using 2 fingers?

▼魔方 西西 提交于 2019-11-30 10:25:57
I've got a UIWebView embedded in my iPhone app, and I'd like to keep a locked header and footer DIV on the page at all times, with a scrollable center DIV. I know that I could do this using a header/footer that are UIView controls, but I want the header and footer to be HTML divs, as a pure HTML/JS/CSS solution will be easier to port to Android/PalmPre/AdobeAir, which is going to be on my todo list relatively soon. I can do this using techniques like the one mentioned here: http://defunc.com/blog/?p=94 But this requires that the user use 2 fingers to scroll the div, which is not satisfactory

EXC_BAD_ACCESS in UIWebView

三世轮回 提交于 2019-11-30 10:24:49
问题 I just downloaded the crash reports for one of my iPhone apps from iTunes Connect. The most common crash has a trace like the following: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0xa1b1c1db Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x3030e6f4 objc_msgSend + 16 1 UIKit 0x30ebebee -[UIWebView webView:resource:didFinishLoadingFromDataSource:] 2 UIKit 0x30ebe5ca -[UIWebViewWebViewDelegate webView:resource:didFinishLoadingFromDataSource:] 3

objective c send cookies to uiwebview

淺唱寂寞╮ 提交于 2019-11-30 10:09:50
I need to send cookies for login to a UIWebView, but when I load the web page the cookies haven't been sent. My code is: CorreoViewController.m - (void)viewDidLoad { [super viewDidLoad]; self.title =AMLocalizedString(@"Correo", @""); NSURL *url=[NSURL URLWithString:@"https://cuentas.uv.es/cgi-bin/p/user/Usuario"]; NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url]; NSArray * cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; NSDictionary * headers = [NSHTTPCookie requestHeaderFieldsWithCookies: cookies]; [request setHTTPMethod:@"Post"]; [request

uiwebview and huge memory loss

喜夏-厌秋 提交于 2019-11-30 09:12:39
I have a problem using UIWebViews, I've seen the same question here but there wasn't helpful answer. the question is here: UIWebView memory management . I will quote it: I am developing an application that makes heavy use of UIWebView. This app generates dynamically lots of UIWebViews while loading content from my server. Some of these UIWebViews are quite large and have a lot of pictures. If I use instruments to detect leaks, I do not detect any. However, lots of objects are allocated and I suspect that has to do with the UIWebViews. When the webviews release because no longer needed, it

UIWebView modal YouTube player “Done” button action

烈酒焚心 提交于 2019-11-30 09:04:36
In my iPhone app, I'm presenting a modal view controller from a home screen with a UIWebView that displays an "inline" embedded YouTube video using this: UIWebView *youTubeWV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 220)]; [youTubeWV loadRequest:[NSURLRequest requestWithURL:sourceURL]]; //NSString *youTubeVideoHTML = [NSString stringWithFormat:@"<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=CadgUJRZfEE\" type=\"application/x-shockwave-flash\" width=\"320\" height=\"220\"></embed>"]; NSString *youTubeVideoHTML =@"<html><head>" "<meta name = \"viewport\" content = \

iOS 8 youtube video embed

依然范特西╮ 提交于 2019-11-30 08:57:53
I'm facing problems that I can't seem to understand. I have this code that works perfectly in Xcode 5 with iOS 7: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CGFloat width = self.view.frame.size.width; CGFloat height = self.view.frame.size.height; UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; NSString* embedHTML = @"\ <html><head><meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; user-scalable=0;\"/>\ <style type=\"text/css\">\ body {\ background-color:

set a delegate for UIWebView

萝らか妹 提交于 2019-11-30 08:49:56
How do I set a delegate for my UIWebView to use webViewDidFinishLoad ? Matthew Frederick In the interface file indicate that you're interested: @interface SomethingController : UIViewController <UIWebViewDelegate> { Then in your implementation you'll add that delegate method: - (void)webViewDidFinishLoad:(UIWebView *)webView { // Do whatever you want here } Obviously SomethingController should be your actual controller, and UIViewController is whatever you're actually implementing. This, by the way, is basically how you implement any delegate. Edit In a window-based app, assuming your

Clearing UIWebView's Cache in Swift

走远了吗. 提交于 2019-11-30 08:40:32
I have a UIWebView inside my app. This UIWebView needs to be reloaded fully (i.e. clear all cache of images/HTML/cookies etc.) every time when viewDidLoad . So is there any code I can do this in Swift? Here is my code: let myUrl = NSURL(string: "http://www.example.com") let myRequest = NSURLRequest(URL: myUrl!) myWebView.loadRequest(myRequest) Thanks! rakeshbs You can use NSURLCache.sharedURLCache().removeAllCachedResponses() NSURLCache.sharedURLCache().diskCapacity = 0 NSURLCache.sharedURLCache().memoryCapacity = 0 Swift 3.0 URLCache.shared.removeAllCachedResponses() URLCache.shared