Detect Tab Selection : Tab Bar Controller - ipad

I have five tabs in my tab Bar Application. I have give access to 3rd tab on if user enters correct password in popOverController. I wanted to present that pop Over Controller when user taps(selects) that 3rd tab. How should i do it.
Thanks in advance.

Take a look at the UITabBarControllerDelegate Protocol Reference.
In particular consider implementig the tabBarController:didSelectViewController: method of the beforementioned protocol, or even better the tabBarController:shouldSelectViewController: method.

Use UIPopovercontroller to present the login form on ebtering into the tabbarcontrollerview which mean first action in viewdidload. Then verify credentials and remove the login popover. Thats it.

Related

Returning to login page after registration is done

How do you return to a previous page after it has been left. For example my app opens to the loggin screen, you can login or register when you register it takes you through a multipage and multi view controller process. When the registration finishes I want them to be taken back to the starting loggin page.
Can anyone help me on how to do that?
You want to use either dismissViewControllerAnimated, which you would use for example if the View Controller was presented modally. You might also want to try popViewControllerAnimated if you are using Navigation Controller.
I'd recommend reading the UIViewController Class Ref or the UINavigation Controller Class Ref.
If you are using a navigation controller (which would be highly recommended in a multi-VC process) the best solution would be using Unwind Segues.
You can see Apple's Documentation on using them, but to briefly explain the process:
Create a method on your login page with the signature #IBAction unwindToLogin(segue: UIStoryboardSegue)
Create a segue in the View Controller you want to go back to the login screen from that leads to the view controller's exit icon. The exit icon is shown below
When creating the segue, select the unwindToLogin function and give it an identifier if you are planning to call it programmatically.
Treat it how you would any other segue, and it should work!

Conditionally Produce two different view controllers from single UITabBarItem

I'm writing an iOS application that includes a UITabBarController, where one of the tabs is the user's profile. However, if the user is not signed in, I would like the application to display a different ViewController (Sign in/Sign up) instead.
I currently have the profile tab routing to a navigaion controller which has its RootViewController as ProfileViewController. In ProfileViewController's viewDidLoad, I have a check to see if the user is signed in. If the user is not, It performs a segue to SignInSignUpViewController which eventually loops back to ProfileViewController.
This approach is over-complicated and broken in a couple ways. For example, the navigation controller allows for the user to back into the signup/signin view controller after they've already signed in.
I feel like this is a pretty common idiom in iOS, but I can't find a good solution online. Anyone have any ideas?
Thanks in advance!
You might want to take a look at the UINavigationController method – setViewControllers:animated:. After you've logged in call this and pass your profile ProfileViewController. It will then be at the top of the stack, so the user won't be able to navigate back to the login view controller.

How should login screen appear on start of application IOS

I am making a new application there i have 5 tabs in it, its a user based application so i have to get the credentials of users login and passwords .
I am using storyboards with Arc , since its a Tabbed application so my initial view controller is my tab view controller , I wish to add a login screen also (probably as Modal View or an).
I am not able to think the perfect way to add a login screen in the tabbed application .
Should i call it from app delegate or in view will appear or some of these methods . I tried some of the code but ended up with warning like unbalanced call etc.
Need your valuable suggestions :)
Thanks in advance !!!
Just two options (of course there are more):
Use one UIViewController as rootViewController in the beginning of your App. Once the login is successful it will switch the window's rootViewController.
Put the UITabBarController as rootViewController, on viewWillAppear, check if the login has been made, if not, just show the Login's UIViewController

iOS - running code on tab change

I have multiple tabs that each does something that may interfere with stuff going on the other tabs if not stopped. In case a user forgets to turn off function in one tab before going to the next tab, I want to know if there is a way to run a block of code from the UIViewController when the user clicks the other tab in the UITabBarController.
You should implement UITabBarControllerDelegate protocol in the view controller that has access to the business logic of your stuff. So you can do something when a user tries to click another tab.
It is very likely that you need to implement:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:
See documentations for UITabBarControllerDelegate.

Adding control method(s) to button created in storyboard ?

I'm trying to add some finer control to the Storyboard controller and I hit a blockage with the back button.
I have a basic Storyboard with push transition. I want to be able to catch when the user presses on the back button (the one generated automatically) and decid if I want the view to go back or not.
The scenario is to show a message to the user asking if he wants to go back warning him that he is going to lose his work if he does,
Sounds simple, yet I can't find how to do it.
Any ideas
You don't get any sort of message by default when the back button is pressed. If you want to provide this sort of functionality, you have two options:
1) Provide a custom back button and set it as the leftNavigationItem of your UIViewController's navigation bar
2) Subclass UINavigationController and override a method such as popToRootViewController:animated:
Try using UIAlertView Delegate.
In your buttonPressed Action, provide an alert view with message with two buttons YES and NO.
define button at index action for YES and NO -ie- YES: dismiss current view and NO: remain on current view.
Search Apple Docs on alert view delegate

Resources