2
votes

I'm having an annoying problem which takes the best off me :<

I've got 3 view controllers, one to show an advertisement in detail which also has a toolbar. Now what I want is, if the user presses the facebook icon on my toolbar in the first view it has to perform a check. If the check turns out false it needs to go to a 2nd view which shows a login screen. If the user logs in here it has to go to a 3rd screen which shows a simple input + button to update their status.

When the user is at this third screen there should be a button "Back", but this button shouldn't bring them back to View2 but it should bring them back to View1 (the advertisement detail screen).

I figured that I wanted to show the 2nd screen (if check turns false) without pushing it but keeping the NavigationBar + TabBar presented. I added some screenshots to clarify.

First view First view, detailed advertisement information

Second view If the user clicked on the Facebook icon and the user is not known, this view will be presented. If the user IS known, view 3 will be presented I want this view to be presented without using PushViewController but keep the NavigationBar and TabBar.

Third View Third view, if you press Back View1 has to be shown

I hope this is enough information, hopefully someone can help me.

Thanks in advance!

4

4 Answers

5
votes

Perhaps the most natural thing to do here is to present the login view controller modally. When the user has logged in successfully, the first controller can then push the third view controller onto the navigation stack. This way, the back button will lead directly back to the first view controller, and the user will understand why.

2
votes

So if we have three UIVIewControllers:

DetailViewController FacebookLoginViewController UpdateViewController

We have two viable options:

1) Upon successful login...pop the current LoginViewController and then push the UpdateViewController

PopViewController(detailViewController, false);
PushViewController(updateViewController, true);

2) Present the login Modally and simply present the UpdateViewController

PushModalViewController(loginViewController, true);

//ascertain result of login

if(IsLoggedIn) {
    PushViewController(updateViewController, true);
}
0
votes

Try to pop the current view controller (without animation i guess) before pushing the new one. If there is only one view controller in the navigation stack no back button will be shown.

Haven't used Monotouch but i guess something like this:

this.NavigationController.PopViewControllerAnimated(false);
this.NavigationController.PushViewController(newViewController, true);

But as Caleb suggests it's probably better figure out a way that fits the normal navigation behaviours instead of hacking around it.

0
votes

consider the following view push logic.

if (!login) {
    LoginViewController *lvc = [[[LoginViewController alloc] init] autorelease];
    [self.navigationController pushViewController:lvc];
}
else {
    ThirdViewController *tvc = [[[ThirdViewController alloc] init] autorelease];
    [self.navigationController pushViewController:tvc];
}

It is : create and push the view controller when it is needed.