UIWebView to View Controller? - iphone

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

Related

The best way to implement a login page in iPhone app?

I have been searching the net, and i have found many very good examples on how to create a login page for your iPhone app. However... none of then meets my demands, an since i am new to iPhone development( i know java / c / C++ and objective-c), so the programming itself is not the issue.. The issue is where to put the code and what design patterns to use..
My app is a basic tabbar controller with 3 tabs that could contain navigation controllers, but that is not important.. it is the part before the tabbar controller i am interrested in, namely the need to authenticate the user towards a Lotus Domino Server. I have the authenification code working, so that is not the issue either..
By the way, i am concentrating on IOS5 and using storyboards..
Where do i put the "check if user is still authenticated" code ? The domino server will log the user out after 1 hour, so if the user has the app open(in background) then the code that downloads data will die if the user is not told that the session has expired..
So here is what i would like..
When the app launches, show the login page. This is working for now with the Login View Controller as initial controller, and a modal segue to the tabbar controller..
Next time the App is launched(either from background or from new is user has closed it completely), check if username and password is stored in userdefaults, and then just login in background, and if that fails(password has changed or another failure) then show the login view controller again..
So to sum up, where do i put the "part 2" code ? I have a seperate authenticator class that is using delegates, and i can use this class to perform the authentification, and the it will answer back if all is good.
Do i put this in the AppDelegate code ? If i put it in one of the tabbar viewcontrollers, then there might be an issue with the user having tab2 open when launching after 2 hours, and if the check is in tab1, then tab 2 will fail.. Should i put the code in ALL the tabbar viewcontrollers ? Naaa, that is ugly..
I am leaning towards the AppDelegate(appdidbecomeactive), but can that be used as delegate in my authenticator class ?
That was a bit long, sorry for that, but i needed to explain my problem fully so people would understand what i need..
Thank you for your help.. This is my first post, but this forum is fantastic :)
I'd definitely put both part one and part two code in the AppDelegate.
This allows you to create the appropriate viewcontroller at app start and remove the tabbarcontroller from within the AppDelegate if the authentication times out etc.
I'm not sure about your modal segue to a tabbarcontroller though (I'm not familiar with storyboards yet though). Modal implies you wouldn't be able to present any other view modally on top of the tabbar controller. I think it sounds like it would be much more appropriate to create your logincontroller and tabbarcontroller programmatically and add/remove them directly in your application’s main window as needed from your AppDelegate.
I would tell the AppDelegate to check the login status very time the tab is changed or data loaded.

A Label in View with UIWebView

I have a View, i would like to put a test ( a UILabel) witch when clicking it, it open me a web View with an URL ( WWW.mySite.com).
How i can do this please ?
thanks for your answers
Use a button, put the text into the button, hook up the actions from the button pressedUpInside to a function which will call the UIWebView's - (void)loadRequest:(NSURLRequest *)request with your URL.
Look up Apple documentation on UIWebView and use a UIButton connected to an IBAction. Always turn to the documentation when these kinds of questions come up. It is really through and usually pretty well done.

Force JQuery Mobile page inside UIWebView to call webViewDidStartLoad

In my iPhone app I've got the following hierarchy:
UITabBarController ->
UINavigationController ->
UIViewController<UIWebViewDelegate> ->
UIWebView
(jQuery Mobile-page)
In the UIViewControllers navigationItem, I've added a button whose action selector is the UIWebViews goBack-function. When the button is pressed, everything goes according to plan - the UIWebView navigates backwards (including the fancy jQuery Mobile-transitions).
The problem is that, since jQuery Mobile uses some kind of "internal linking" when navigating to different pages (adding #the/newPage/url.html to the URL), the UIWebViewDelegate function webViewDidStartLoad is never being called when pages within the same jQuery Mobile-driven site are loaded.
Anyone with suggestions on how to make the jQuery Mobile-page fire off the delegate function? Possibly with maintained transitions. If this isn't possible, do anyone have suggestions about any other "web app framework" that is capable of this (delegate calls + transitions)?
Thanks!
UPDATE
Maybe my question is almost the same as this one here on stackoverflow, but I at least think that mine is a bit more specific. If you disagree, leave a comment :)

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.