URL Loading Problem - iphone

I parsing the "http://feeds.epicurious.com/newrecipes" URL and i read the URLs as following format.
http://feeds.epicurious.com/~r/newrecipes/~3/TGBDO1Ld400/361889
When i put this above Url in UIWebview, it does not work.
But When i put this URL in web browser it will change automatically as the following format.
http://www.epicurious.com/recipes/food/views/Cherry-Cranberry-Sauce-361889?mbid=rss_epinr&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+newrecipes+%28Epicurious+-+New+Recipes%29
How to solve this issue. If anybody having any idea please answer me.
Thanks..

I was able to get that same link to load with a stock iPad split view controller that only contained an outlet to a UIWebView named "viewer". I called this code from viewDidLoad: in the root view controller:
[detailViewController.viewer loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://feeds.epicurious.com/~r/newrecipes/~3/TGBDO1Ld400/361889"]]];
Hope that helps.

Related

UIWebView to View Controller?

I was wondering if anyone knew if this was possible?
I have a uiwebview as the first view controller which is showing a basic html page I made with the Facebook login screen. Can you login (in the uiwebview) and once it authorises you (in the uiwebview) it closes and launches the second view controller?
Does anyone know of a good example or tutorial for this?
If not can someone point me in the direction of a good FacebookSDK example or tutorial in Storyboard not XIB?
Thanks!
You should be using the FBLoginView and FBSession classes of the Facebook SDK to log in. You can just use the delegate callbacks from those to drive your next view controller.
I can't think of a reason you would want to bring up the facebook login page in a UIWebView , rather than doing the above. If for some reason you actually need to use a UIWebView , the webViewDidFinishLoad: method of UIWebViewDelegate might provide you with the hook you need.
Download the Facebook sdk from github and check the SessionLoginSample in samples. I think it has everything you need

url from webview iphone

Hi I just wanted to know how to extract url from webview after loading the web view with the method [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://m.nytimes.com"]]];
In this, I am loading the page with nytimes. When the user navigates to the new page I wan to find out the url the moved page. Is there any way I can find it?
Thanks
You will need a class to implement the UIWebViewDelegate Protocol, then set an instance of that class to be the delegate of the webview. The method you will want to implement is:
- (void)webViewDidFinishLoad:(UIWebView *)webView
In that delegate method, you can get the url by inspecting the request property of the web view.
Edit: Changed the recommended delegate method due to Anomie's comment pointing out my failure to see the request propery of UIWebView.

Updating address bar with current url from UIWebview

Like iPhone safari browser, I want to update UItextview with current url of UIWebView
I tried shouldStartLoadWithRequest delegate method, but I end up with url of some ads/iframe
If I use webViewDidFinishLoad delegate method, then address bar gets updated at the end of the request.
Please help me on the best approach.
You want to use the mainDocumentURL method on the NSURLRequest in webView:shouldStartLoadWithRequest:. This should contain the main document URL regardless of whether the page is loading or a resource on the page (e.g. a frame) is loading.
Use webviewDidFinishLoad when delegated from your webview, and then query it for the title with [webview stringByEvaluatingJavaScriptFromString:#"document.title"] or weboutWebView.request.URL.absoluteString for the url.

How do you put a UIWebView somewhere other than MainView.xib?

I've been trying to put a UIWebView into my app, which is tableview based.
When the user selects a row, I want the new xib to load, but this one with a UIWebView on it.
From all of the tutorials I've seen, you can only put a UIWebView on the MainView.xib.
Can someone please tell me how to put a FUNCTIONING UIWebView somewhere other than the main view?
Thanks in advance!!
You can put a UIWebView in any XIB you want. Why do you believe that it has to be in MainView.xib? Tutorials generally put everything in MainView.xib because they're keeping things simple. What problem are you having when you put it elsewhere?
Can you give a link to the tutorial that indicates that you have to put this in MainView? Can you describe what "doesn't work" actually means? Does it fail to display, fail to make callbacks, fail to load pages, render incorrect?

Loading url's in UIWebView

I have a UIViewController with a webView in it.
When tapping on a link, I would like to push a new controller and open the url in a new webview.
Is that possible?
Thanks in advance for your help.
You need to implement webView:shouldStartLoadWithRequest:navigationType: (docs here), push your new controller and return NO.
I imagine that you've already got a handle on loading a URL into a WebView so I leave it at that.