A
A
Anton Parfenov2016-01-29 17:56:33
iOS
Anton Parfenov, 2016-01-29 17:56:33

How to make an authorization pop-up window correctly when you go to the "Personal Account" uitabbaritem?

Hello!
Can you please tell me how to correctly open the authorization window?
I'm making an application like Avito's, there is a "My Account" tab, so when I click on it, if the dude is not authorized, you need to show the view with the login (there is also a transition to the reg)
Now I have done this:
In the controller "my account"

override func viewDidAppear(animated: Bool) {
        if (authorization == 0) {
            dispatch_async(dispatch_get_main_queue(), { () -> Void in
                self.performSegueWithIdentifier("Login", sender:self)
            })
        }
    }

And in the "Login" controller, the cancel button, which closes the login:
override func viewDidAppear(animated: Bool) {
@IBAction func CloseLogin(sender: UIBarButtonItem) {
        self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
        self.navigationController?.tabBarController?.selectedIndex = 0
    }

After closing, I want to go to the first tab, but self.navigationController?.tabBarController?.selectedIndex = 0 doesn't work :(
Maybe the screen will help to understand: https://yadi.sk/i/z0seo7oCnwVTj
Who can tell me what?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Elchev, 2016-01-31
@rsi

Firstly, it is not clear why to implement a personal account with a tab. Secondly, it is not visible from the skin that it is tab. Thirdly, it is not entirely clear what you want to do.
1) Have you tried step by step through the code with a debugger? If not, do it, you will immediately understand what is happening there. If yes, what is going on there that is not clear?
2) the obvious jamb is that you have such a structure there
tabBarController-> personal account
navigationController-> authorization
And roughly speaking, authorization belongs to navigationController and the expression self.navigationController? correctly on the login screen.
But tabBarController is on its own, it has nothing to do with the login screen and its navigationController, so the expression self.navigationController?.tabBarController? not correct. Do you need to do something like this personal account? .tabBarController? .selectedIndex = 0 in order to pull something in one controller while in another, you need to use delegates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question