I'm using StoryBoard, and I have UITabBarController and an UITabBarItem (User Profile). When I click on UITabBarItem (User Profile), I want to check if the user is connected or not before the view is shown. I have two ViewContollers, one for sign in (SignInVC), and the other one to show the user informations (UserProfileVC).
What I want is this: if the user is connected, show the UserProfileVC; otherwise show the SignInVC.
How can i implement this?
This seems to be a very common problem that people get stuck on. I would make the UserProfileVC the controller in the first tab of the tab bar controller. In its viewDidAppear method, add logic to determine whether you want to show the SignInVC or not. If you do, use presentViewController:animated:completion: with animated set to NO, to display that controller -- it will be the first thing the user sees, if you choose to show it. If the user successfully logs in, dismiss that controller with dismissViewControllerAnimated:completion:.