uiwebview

The UIWebView doesn't display url

不羁岁月 提交于 2020-01-06 14:39:07
问题 I Load UIWebView using this code : NSString *a=@"http://www.google.com/"; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:a]]; [aWebView loadRequest:theRequest]; But nothing is loaded? What I do wrong? Please help me 回答1: try This code may be helped............ UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(50, 100, 690, 750)]; //webView.delegate=self; NSString *urlAddress = @"http://www.google.com/"; NSURL *url = [NSURL URLWithString:urlAddress];

UIWebview xml file

大城市里の小女人 提交于 2020-01-06 14:27:19
问题 I've been trying to display a xml file in my uiwebview. I've tried using NSURLRequest but the UIWebview shows up blank. I am able to display a local xml using the code below. Is there a way pull this from a defined website rather than from local file or maybe download the file then display it? NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"location" ofType:@"xml"]; NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile]; [aWebView loadData:htmlData MIMEType:@"text/text"

Unable to load html string in UIWebView using loadHTMLString, It is showing a white page

风流意气都作罢 提交于 2020-01-06 07:05:46
问题 I am facing a problem with UIWebView . I am trying to load an HTML string which will load other downloaded files(js files, css, html and xml files) to load some contents in custom player inside UIWebview .Same thing is working in android so I don't think there is issue in files. But in iOS it showing a white page. I have tried all suggestions in other similar questions in stack overflow. I have already checked if the files are properly being downloaded or not. Everything seems fine. I can see

How to create then destroy a UIWebView inside a class file

痴心易碎 提交于 2020-01-06 06:49:10
问题 I am trying to dynamically create a UIWebView inside a class file upon launching the application. I have successfully gotten a function to be called inside that class file upon launching, but when I add the the code to create the webview to that function, I am getting errors like this: " Tried to obtain the web lock from a thread other than the main thread or web thread. This may be the result of calling to UIKit from a secondary thread. Crashing now... " My code to create the UIWebView is

Using UIWebView links to call a function?

不羁岁月 提交于 2020-01-06 06:09:55
问题 I'm using a UIWebView to display formatted text from local HTML. Is it possible to have specific links in the HTML call Obj-C functions? For example, clicking a link to have a new view appear? Or am I resigned to using Javascript? 回答1: You can use UIWebViewDelegate:shouldStartLoadWithRequest:navigationType: to intercept the URL and do something with it. E.g. if ([[request.URL absoluteString]compare:@"http://somelink"] == NSOrderedSame) { [self someFunction]; return YES; // return NO to

iPhone - Disable UIWebView from prompting to enable location services

旧巷老猫 提交于 2020-01-06 02:53:31
问题 During the development of my iPhone app, I decided to integrate Google Maps by including a UIWebView with a URL I construct pointing to maps.google.com. The problem is that the website tries to get the user's location, displaying the "This app wants to use your location". This creates a number of issues for me, which I can explain if necessary. Is there any way to disable the UIWebView / Mobile Safari from asking for the user's location. The only workaround I can think of is to use Google's

Get caret rect in content-editable UIWebView when it's on a blank line

↘锁芯ラ 提交于 2020-01-06 02:48:27
问题 For some reason, I need to get the caret vertical position in a content editable UIWebView. As many methods to do that stop caret blinking (for example when creating/removing a hidden node), I use this javascript/Objective-C code: - (CGRect)caretRect { NSString *js = @"function f(){ var sel = document.getSelection(); var range = sel.getRangeAt(0).cloneRange(); range.collapse(true); var r =range.getClientRects()[0]; return '{{'+r.left+','+r.top+'},{'+r.width+','+r.height+'}}'; } f();";

UIWebView - Add an extra parameter to the url request

被刻印的时光 ゝ 提交于 2020-01-05 16:55:07
问题 Hi I have a url say http://www.foobar.com [webView loadRequest:[NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0 ]]; Now when this url is formed i can set the urlString to have webtype=iphone But for every single request that comes from there onwards I need to add webType=iphone to back of the string. I figured there is some way using - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:

How do I download an entire webpage (with images) on the iPhone?

半腔热情 提交于 2020-01-05 12:12:20
问题 Is there a way to download an entire webpage for offline viewing with the iPhone SDK? I can use NSString with the contents of the URL, but that would just give me the HTML and no images. Is there any way to do it? 回答1: The popular open source library ASIHTTPRequest has a class that will do just this for you: download all HTML, images, and other resources associated with the page you're requesting. It's called ASIWebPageRequest , and you can read the documentation and download it from here:

Send path of SDWebImage stored image to a UIWebView

一笑奈何 提交于 2020-01-05 12:07:20
问题 I need to be able to get a path to images that cached. While I am wondering if there is a way to do this using SDWebImage, I could probably get away with just having the knowledge to return a path to an image stored in the cache so I can display it within a uiwebview inside an image tag. 回答1: According to this https://github.com/rs/SDWebImage/issues/25 it would seem you can simply refer to the image by it's original url and it will be correctly picked up from cache. 来源: https://stackoverflow