Skip to main content

Posts

Showing posts with the label uiwebview

UIWebView - When (or how) does CFData get released?

after multiple days of banging my head against the wall and having sleepless nights I'm hoping to find some help here. I've gone through various posts here, but none of the answers seem to provide a resolution for me. In short, my problem is that my App crashes after heavy usage (>10min) of the UIWebView (e.g. opening larger news paper sites in series - one after the other). To give more details: I am writing an iPhone App and from the MainViewController I push a browserViewController on the navigationController. The browserViewController loads a nib which contains a UWebView (I do not create the WebView programatically). The UIWebView is wired up using Interface Builder. When going back to Main and then going again to the browserViewController, I only recreate the browserViewController if it is nil. (I want to keep the content that is loaded i the UIWebView - only if there is a memory warning shoud this view be unloaded and release all memory used). In both, MainV

How to handle app URLs in a UIWebView?

I recently found that my UIWebView was choking on ITMS links. Specifically, from the UIWebView in my app, if I navigate to a site such as this one and click the "Available on the App Store" link, UIWebView would error out with "Error Domain=WebKitErrorDomain Code=101 The URL can't be shown." After a bit of Googling, I realized that I needed to catch requests for app links and have iOS handle them. I started out by looking to see if the scheme starts with "itms" in -webView:shouldStartLoadWithRequest:navigationType: , but realized that there might be other kinds of app links that the system can handle. So I came up with this, instead: - (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error { // Give iOS a chance to open it. NSURL *url = [NSURL URLWithString:[error.userInfo objectForKey:@"NSErrorFailingURLStringKey"]]; if ([error.domain isEqual:@"WebKitErrorDomain"] && error.code == 101

Force a WebView link to launch Safari?

I have a UIWebView embedded within an iPhone app of mine. I want to be able to have certain links within that webview open into the full Mobile Safari app (i.e. not my embedded version of it). Is there a simple way to structure some of my hrefs to force this, instead of every link opening within my embedded webview? Thanks.

Open MWPhotoBrowser with a link and loop

I'm fairly new at iOS development so please forgive my ignorance. I have web view with a search form, sending request to display different pages depending on the search query. When displaying a selected page I want to have a normal html link at the top which will give the user the possibility to display all images available using the very nice MWPhotoBrowser. So somehow I need to tell Xcode to open MWPhotoBrowser using a link and when this link is pressed send a variable to MWPhotoBrowser and in that viewController somehow loop through a my url.com/variable. Is this the best way to do this and is it even possible? I have searched as much as possible but I'm not sure what to look for so I would really appreciate if you could point me in the right direction.

Loading NSData into a UIWebView

In my web browser, I am trying to load a UIWebView with NSData obtained from an NSURLConnection. When I try to load it into the UIWebView, instead of the site, it comes up with the HTML plain text. Here is my code: in viewDidLoad: NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://www.msn.com"]]; [NSURLConnection connectionWithRequest: request delegate:self]; later in the code: -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ webdata = [NSMutableData dataWithData: data]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection{ [webview loadData:webdata MIMEType: @"text/html" textEncodingName: @"UTF-8" baseURL:nil]; }

iOS WebView > Display only main-content from a website including pictures

How do I fetch just the main-content part of a webpage and display it in an UIWEBVIEW? Link to the page When I look at the code of the webpage I see that the 'What is new?' posts appear below: <div id="content-header" class="clearfix"> <a name="main-content" id="main-content"></a> <h1 class="title">Aktuell</h1> </div> <!-- /#content-header --> Is it possible to relate to id="main-content within the UIWEBVIEW to display just this part of the website instead of the whole page? Screenshot shows visually what I like to get. P.S This is my code to display the whole webpage: - (void)viewDidLoad { [super viewDidLoad]; NSString *golfClubURL = @"http://golfplatz-altenstadt.de"; NSURL *loungeURL = [NSURL URLWithString:golfClubURL]; NSURLRequest *myrequest = [NSURLRequest requestWithURL:loun

Create a proxy within the iOS app

I have an app with an UIWebView (which is connected with a website); the user will navigate into the website. After that, I want that when the user open the app and there is no connection, the already visited pages will be accessible. So I though that it should be possible if I create an internal proxy within the app: each request will be processed by this proxy (and will send the result to the UIWebView). Of course, the proxy should cache the web pages and, if there is no connection available, use the cached pages. I prefer this approach instead of others (HTML5 offline cache) because, in the future, I will can set some feature to the proxy, for example "I want to cache all the pictures for the next 5 hours" etc... Do you know if it's possible and, if it is, what should I use to do it? Or... do you know if there is something similar already done (some Objective-C Proxy?) ?

Input HTML code in UIWebview

I have a header string, footer string and body of the HTML page. I need to programmatically include some text in the body and then I need to input all this data in a UIWebView to load the page. I need to input the final HTML string into a UIWebView controler, so that it will launch the page I designed. Could someone please share your ideas how can I achieve this? Thanks!