uiwebview

How to mock AJAX call with NSURLProtocol?

好久不见. 提交于 2019-12-17 18:27:12
问题 I have UIWebview that makes AJAX calls to external services. When offline i need to catch theses requests and return local json. I implemented a NSURLProtocol and i manage to catch the AJAX request, the problem is jquery always return a 0 error code : $.ajax({ url: url, dataType: 'json', contentType: "application/json", success: function(jsonData){ alert("success :"); }, error: function (request, status, error) { alert("failure :" + request.status ); } }); I always get a request.status = 0 To

UIWebView display locally stored website (HTML, images, Javascript)

大憨熊 提交于 2019-12-17 17:59:14
问题 I've looked EVERYWHERE for this, can't find anything. I basically need to store an entire website inside of my iPhone for some interesting reasons. Regardless I can't figure out how to display it correctly in my UIWebView. EDIT: I should clarify, I can load the original HTML file, and I have chagned all of the pathing to be local, except nothing gets linked in. Here is the code self.dataDetectorTypes = UIDataDetectorTypeLink; NSString *path = [[NSBundle mainBundle] pathForResource:@"index"

UIWebView with Progress Bar

老子叫甜甜 提交于 2019-12-17 17:38:18
问题 Hi I'm new to programming and I'm trying to make my first app for iPhones on Xcode. My app contains of a button which opens a UIWebView when pressed and loads up a homepage. Now I also want to add a Progress View to the WebView like Safari also uses, which indicates the progress of loading the page. How can I do that? My code so far for loading the URL in the UIWebView: .h IBOutlet UIWebView *webView; .m - (void)viewDidLoad { [webView loadRequest:[NSURLRequest requestWithURL: [NSURL

Getting the HTML source code of a loaded UIWebView [duplicate]

青春壹個敷衍的年華 提交于 2019-12-17 17:30:47
问题 This question already has answers here : Reading HTML content from a UIWebView (10 answers) Closed 6 years ago . How can I get the HTML source code of a UIWebView and store it in NSString ? 回答1: If you want the source code of an already loaded webview, you can get it like this: NSString *yourHTMLSourceCodeString = [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"]; Update: method above works most of the time. But I recently was in a situation where I needed all the

showing custom menu on selection in UIWebView in iphone

五迷三道 提交于 2019-12-17 17:26:58
问题 I want to show 2 options like "hi" & "bye" when user completes selection on UIWebView. I have added observer to my view controller as follows. But I don't know further implementation. [[UIMenuController sharedMenuController] addObserver:self forKeyPath:UIMenuControllerWillShowMenuNotification options:nil context:nil ]; 回答1: Sagar, Your question is a couple of months old, but I finally figured this one out, so I figured I'd answer it in case it helps out someone else. I added the following

iOS UIWebView inside a UIScrollView

佐手、 提交于 2019-12-17 17:26:31
问题 I want to have a UIWebView inside a UIScrollView . The UIWebView will sometimes go out of bounds of the iPhone screen so I need a way to scroll the view so I can see all the content (but I don't want to use the built in scrolling of the UIWebView). So I'm thinking of putting all the content inside of a UIScrollView and then making the height of the UIScrollView to equal the height of the UIWebView and other views that are in it. Here's an image to help describing my problem: 回答1: I did

Remove Next / Previous buttons (inputAccessoryView) for Custom Keyboard in iOS8 WebView

孤者浪人 提交于 2019-12-17 16:37:08
问题 Please bear with me, I searched a lot over the internet and I couldn't find a solution since it's a new API. I am trying to create a custom keyboard for iOS 8. It works perfectly fine except in WebView! It has previous-next button, which are in inputAccessoryView . I know it's read-only property for webview but since iOS 8 allows the users to have custom keyboard I assume this view should be editable somewhere. Has anybody run into the same issue? Any help would be appreciated. 回答1: You may

What's the best approach for parsing XML/'screen scraping' in iOS? UIWebview or NSXMLParser?

吃可爱长大的小学妹 提交于 2019-12-17 16:30:10
问题 I am creating an iOS app that needs to get some data from a web page. My first though was to use NSXMLParser initWithContentsOfURL: and parse the HTML with the NSXMLParser delegate. However this approach seems like it could quickly become painful (if, for example, the HTML changed I would have to rewrite the parsing code which could be awkward). Seeing as I'm loading a web page I took take a look at UIWebView too. It looks like UIWebView may be the way to go.

how to play local video file?

余生颓废 提交于 2019-12-17 15:57:10
问题 I have created .mov video file with my screen(desktop) capture software and I want that video to play in my application in UIWebview. Is there any way to play that video or any other way so that I can create a URL for my local video ??? Right now I mm using a default video link for playing video in UIWebview. Here is the code : - (void)applicationDidBecomeActive:(UIApplication *)application { self.viewVideoDisplay.frame = CGRectMake(0, 0, 1024, 1024); [self.window addSubview:self

Detect when a webview video becomes fullscreen on ios8

感情迁移 提交于 2019-12-17 15:56:41
问题 I have an app where users can open videos from UIWebview, including Youtube ones. In iOS7, I was able to get a notification when it started playing, or when it became full screen, which is vital for me to show certain options to the user and modify the interface. I used to use this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil]; [[NSNotificationCenter defaultCenter]