Refresh Tab View in swift - swift

I made an app with an login system. For those users who logged in I want to show a different content. When i switch through the tabs there is still the content shown, which is loaded when I start the app.
How can I change that?

on each controller, you can refresh the display by loading the content in viewDidAppear instead of viewDidLoad

Related

Login screen shown just once

i'm making app based on tab bar with two tabs. My problem is that i have to implement authentication view "loginView" on one of tabb's view, and when the credentials are saved i want show another data everytime tab is tapped. what's the best way to do it ?
Store a boolean in your user defaults, something like 'loginShown', then, in your appplicationDidFinishLaunching method, check if the 'loginShown' is set, and if not, present a modal view controller which is your login view.
You can use a modalViewController for Login so you can have some other view beneath it. For saving credentials for Login so that the user does not have to log back in, you can store it in the KeyChain.
Use this reference: http://log.scifihifi.com/post/55837387/simple-iphone-keychain-code

Refresh a view on TabBarController

I have a TabBarController, with three views, one of which is the settings view. When I go to the settings page, then come out of the app and go back in, I need the view to refresh. Is that possible?
It depends on what you want to refresh, and what your setting looks like?
If your setting view has a done or save button, you can put the refresh code there, [someController.theTable reloadData] for example.
Another way is to put the refresh code inside viewWillAppear: in the view that you want to refresh, info can be found here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/cl/UIViewController

Reload View only when application is opened Again

My application has tab bar with one of the tabs having a segmented control on navigation bar.
Based on segment clicked different view is displayed using a url.
I am calling the url in viewdidload method.I do not want to use viewwillAppear to call the url as it will be called each time the view is displayed.
I only want to call the url again whenever user closes the application and comes back.
Whats the best way to do this.Should I remove the view controller from and reload it again once the application is opened.
Please use a more descriptive title for your question next time!
There are notifications for this that you can observe in your application:
UIApplicationDidBecomeActiveNotification and UIApplicationWillEnterForegroundNotification come to mind.

UIwebview delays loading

I have Login screen and second view which will be shown after login. On second view I have UIWebview which loads the url.
After login first it shows the empty view and slowly it loads the url. I want to show login screen with wait cursor, until the uiwebview loads the url and then want show that screen.
Can any body please provide code or sample for this?
Regards,
Malleswar
I cannot write your application for you, because it is a large project.
However, you might think about making your own login UIView as a child view of a UIViewController, which contains form elements:
This view controller is the root view controller in a UINavigationController stack.
The user enters her credentials into this form.
On clicking Submit, you push another UIViewController on to the navigation stack that contains a UIView child, that itself has a UIProgressIndicatorView and a UIWebView as children views.
The progress indicator view does its spinning wheel thing while the web page loads with the user's credentials entered in step 2.
Once the web page finishes loading, it fires its delegate method telling you loading has finished. This delegate method tells the progress indicator view to stop spinning and hide.
I would recommend reading up on UINavigationController through Google and Apple's ample documentation and sample projects. One sample project template is included in Xcode, as well.

How do I get a login screen on an iPhone app (using tabBarController)?

I am developing a web app (using rails) that I will be launching within a week. I've "jumped the gun" and started working on the iPhone app for the site (I'm new to iPhone development). Using the peepcode iPhone screencasts and the expense/budget demo app from clarkware I've been able to get things going (using ObjectiveResource for iPhone-to-Rails communication). So I'm able to get a tabBarController loading a table with test data populated from my staging server online. Great.
My problem lies in that I need login functionality. The budgets demo app has this nailed but it uses a navigationController. I would like to use a tabBarController (which I'm using currently) to handle the basic functionality of the app.
Here's how I see the app login functionality working when completed:
When a user first runs the iPhone app, the iPhone app will present a login screen (username and password). If a correct username and password is entered the session/user info is saved (preferably to the general/settings app section of the iPhone). The user won't be presented with the login screen again unless the session expires, the user edits the username/password in the general/settings section of the iPhone, or the user deletes the application and reinstalls.
The closest thing to what I have in mind for this process is the Gowalla app.
So I suppose my question is: What is the best way to get a login screen to appear when using a tabBarController? Once I can do this and get authentication taken care of the rest should fall into place.
Please let me know if there's anything I need to clarify - THANK YOU!
-Tony
Do you want to have the tab bar to display at the bottom? Then just put the Login View Controller as the selected tab by setting the selectedViewController or selectedIndex properties of UITabBarController.
Do you want to have the tab bar display at the bottom but not be actionable until they've logged in? Then set a UITabBarDelegate and override the tabBarController:shouldSelectViewController: method to disallow until login has happened.
Do you not want the tab bar to display until login has been entered (personally I would think this is most desireable)? Then either don't show the TabBarController until you're ready, show the Login View Controller instead... or, alternatively, show the Login Controller as a Modal View Controller over the TabBarController and don't allow it to be dismissed until login was successful.
I am new to iPhone programming, but have done C++ coding moons ago. So far I have created everything programmatically rather than use the nib approach.
For what you what to achieve, I would create a main view controller from the app delegate. Then from this main view controller I would create the login view (UIView) that initially displays and seeks the users login credentials. Once validated, your main view contoller can the create and display (or just display if you created it initially) a tab bar controller with the appropriate view controllers for each tab.
So appDelegate -> Main View Controller -> Logon View
-> Tab View Controller + View Controllers
Hope this helps?!
Matthew.