1

I have a login screen which redirects to home page after a successful login.

I redirect like this:

ViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"main"];

[self presentModalViewController:viewController animated:YES];

and the redirection happens, and the home screen loads, but the buttons on it no longer respond to clicks, and the nav area is missing.

I am using push segues.

Would anyone know why this sort of thing happens? Also, right now I am using push segueys, but should I be using a modal seguey?

My functionality is: do some logic on one screen, go to the next screen.

GeekedOut
  • 16,905
  • 37
  • 107
  • 185
  • This creates a **new** `ViewController`. When you say "redirect", are you sure that's what you intended? – Phillip Mills Jul 31 '12 at 16:42
  • @PhillipMills maybe I am not doing in code what I actually intend. I really just want to swap screens just like in a website when a user clicks on a link the site takes them to a new page. How would I accomplish that? Thanks! – GeekedOut Jul 31 '12 at 16:45
  • Is there anything on the screen before you go to the login...if so, what? What puts the login onto the screen...initial controller, segue, code? – Phillip Mills Jul 31 '12 at 17:21
  • @PhillipMills the user clicks a button to go to the login screen. It is a segue. And once they fill out the login form, and everything is ok, I need to send them to the home screen. Does that help explain it? – GeekedOut Jul 31 '12 at 17:46
  • Right, so if your segue was 'push' type, you should use `popViewControllerAnimated:` on the navigation controller to remove it. If it was modal, then you should look at `dismissViewControllerAnimated:`. – Phillip Mills Jul 31 '12 at 17:59
  • @PhillipMills thank you - that helps me understand what is going on! :) – GeekedOut Jul 31 '12 at 18:15
  • @PhillipMills I ended up checking this, and all my segueys are push, and they all seem to work, but sometimes the header navigation is missing when landing on a screen, and only on the home screen the buttons do not respond to clicks. – GeekedOut Aug 01 '12 at 13:36
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/14751/discussion-between-geekedout-and-phillip-mills) – GeekedOut Aug 01 '12 at 15:45

4 Answers4

2

First, I would create the entire "redirecting" differently. In IB, select the login view controller and drag from it to the home screen view controller and choose Push. Select the segue and add identifier and replace your redirect method with
[self performSegueWithIdentifier:@"identifier set in IB" sender:self];

imas145
  • 1,959
  • 1
  • 23
  • 32
2

This actually happend to me also. What happend was in my case, there was an option called Initial View in the Attributes Inspector. Keep it so that option is checked only for the UINavigation controller itself.

Try that. If it doesn't work, sorry :/

Edit: this is a question I posted a while back for bounty and it details this same problem. Check out the answer.

Community
  • 1
  • 1
chaitanya.varanasi
  • 960
  • 1
  • 9
  • 26
2

You need to understand better how UINavigationControllers work. The reason the buttons arent working is that you have put them on the UINav controller itself and not on the "implied" toolbars that are associated with the view.

UINavigationController swaps out its controls with the controls of the pushed view. If you put controls directly on the UINav controller, your viewController will not get the associated messages.

UINavigationController is a container for views thats it. Go into IB and put your buttons on the toolbar of the views inherited toolbars and it will work.

deleted_user
  • 3,817
  • 1
  • 18
  • 27
1

Are you sure that the View has it's userInteractionEnabled?

[self.view setUserInteractionEnabled:YES];
Ignacio Oroná
  • 4,371
  • 1
  • 19
  • 25