uiwebview

How do I make UIWebView show a pdf file from its own app?

旧巷老猫 提交于 2019-12-19 06:34:06
问题 I really need to make a UIWebView open up a specific PDF document that is in my project directory. I can't seem to find any tutorials on this. I found one, but the author was not specific about some of the code. I have to assume it's got to be quite a simple bit of code. Can someone help me code UIWebView to load a PDF? Thanks. 回答1: Use pathForResource and fileURLWithPath: NSString *path = [[NSBundle mainBundle] pathForResource:@"FileNameHere" ofType:@"pdf"]; NSURL *url = [NSURL

How do I make UIWebView show a pdf file from its own app?

心已入冬 提交于 2019-12-19 06:32:28
问题 I really need to make a UIWebView open up a specific PDF document that is in my project directory. I can't seem to find any tutorials on this. I found one, but the author was not specific about some of the code. I have to assume it's got to be quite a simple bit of code. Can someone help me code UIWebView to load a PDF? Thanks. 回答1: Use pathForResource and fileURLWithPath: NSString *path = [[NSBundle mainBundle] pathForResource:@"FileNameHere" ofType:@"pdf"]; NSURL *url = [NSURL

Show keyboard automatically with focus() event in UIWebView using Trigger.IO/PhoneGap

☆樱花仙子☆ 提交于 2019-12-19 04:15:16
问题 Supposedly, this has not been possible since iOS 6 where you can set the UIWebView's keyboardDisplayRequiresUserAction = NO. I'm using a html 5 webview (Trigger.IO) and building a native plugin but am having difficulty grabbing hold of the UIWebView instance. How do I grab hold of the webview so I can simply do the following: mywebview.keyboardDisplayRequiresUserAction = NO; Probably really simple.. what am I missing? 回答1: Access to the UIWebView isn't something we properly expose in the

iPhone SDK - opening links in a UITextView in a web view

不打扰是莪最后的温柔 提交于 2019-12-19 04:11:01
问题 I have specified dataDetectorTypes on a UITextView so that URLs open in Safari when touched. Is it possible to intercept this behaviour so I load the URL in a UIWebView instead? Or would I have write my own URL detector code to re-route this? 回答1: You would have to do the URL detection yourself and manually load the UIWebView when the URL is tapped. Everything needs to be custom-done because Apple sends all http:// and https:// URL openings to Safari. 回答2: The answer above that works best is

How to set http header in uiwebview if loading view with loadHTMLString

不想你离开。 提交于 2019-12-19 04:04:13
问题 I have a UIWebView that i am loading using loadHTMLString and i need to set cookies on the request header. I know how to do this using loadRequest but not loading the webview with loadHTMLString I don't have the request object. Has anyone done anything like this? 回答1: There will not be any difference between loading web view from loadRequest vs loadHTMLString method, shouldStartLoadWithRequest method will be called in both cases. You can override your headers there and add header as per your

UIWebView and NSURLCache have a troubled relationship

北战南征 提交于 2019-12-19 03:57:01
问题 I am trying to solve 2 things in my UIWebView : Load local assets in place of remote ones, under the right conditions Load remote assets as normal if there are no local ones or they are outdated Allow the webview to go "back" without needing to reload it's html form the server So to handle #1 and #2, I implemented a custom subclass NSURLCache . It gets called when the webview requests assets, and I can send along the local ones instead, aborting the server call for the asset. I even have a

Using a custom NSURLProtocol with UIWebView and POST requests

僤鯓⒐⒋嵵緔 提交于 2019-12-18 20:02:20
问题 In my iOS app, I'm using a UIWebView and a custom protocol (with my own NSURLProtocol implementation). I've been fairly careful about making sure that whenever I load a url, I load something like this into my UIWebView: myprotocol://myserver/mypath and in my NSURLProtocol implementation, I take a mutable copy of the NSURLRequest, convert the URL to http: and send that to my server. Everything works for HTTP GET requests. The problem I encounter is with POST requests. It seems like the

is it possible to free memory of UIWebView?

自古美人都是妖i 提交于 2019-12-18 18:11:57
问题 i'm trying to release UIWebView object but it not free memory. is it have any reason? 回答1: Maybe clearing the cache might help? See NSURLCache class. 回答2: Just because you've released it doesn't mean that it can be released - maybe it's being used by something else? What is it's retain count after you have freed it? [myWebView release]; NSLog(@"%i", [myWebView retainCount]); If this number is not 0, someone else is retaining it as well and it can't be freed until they release it too (or it's

is it possible to free memory of UIWebView?

吃可爱长大的小学妹 提交于 2019-12-18 18:11:40
问题 i'm trying to release UIWebView object but it not free memory. is it have any reason? 回答1: Maybe clearing the cache might help? See NSURLCache class. 回答2: Just because you've released it doesn't mean that it can be released - maybe it's being used by something else? What is it's retain count after you have freed it? [myWebView release]; NSLog(@"%i", [myWebView retainCount]); If this number is not 0, someone else is retaining it as well and it can't be freed until they release it too (or it's

GeneralBlock-56 memory leak when calling loadRequest in UIWebView

荒凉一梦 提交于 2019-12-18 17:26:06
问题 I'm working on an IPad app and have been profiling it using Instruments in XCode 4. I'm profiling on the actual device itself. iOS 4.3 is installed. Instruments tells me I have some memory leaks, the leaked objects being mainly GeneralBlock-56 ones and some GeneralBlock-1024 / GeneralBlock-8192 ones. The interesting thing is that these leaks are reported only when I load up a URL in a UIWebView embedded in my app. If I comment out the loadRequest call, these leaks go away. This behavior is