Jordi Kroon
Jordi Kroon

Reputation: 2597

From view 1 to view 2

I am stuck in my code. I can't make it to go to the other view when a user logins.

I have a class UILoginClass (Tableviewcontroller) And a class ImageViewController (viewcontroller).

Check image below.

I want to get from UILoginClass to ImageViewController but i can't make it. Anyone help?

enter image description here

Upvotes: 0

Views: 94

Answers (2)

PostPCDev
PostPCDev

Reputation: 684

1) Create a "push" segue from the view controller of the login screen to the image view controller (press ctrl and drag from source view controller icon to the destination view controller).

ctrl+drag from source view controller to destination view controller

2) Give that segue an identifier (click on the seque in IB --> attributes inspector --> identifier. It is just a string identifier that allows you to initiate that segue when you want to.

3) In code, when the login is validated, call performSegueWithIdentifier:sender: with the identifier you gave to the segue.

Upvotes: 1

Jay Slupesky
Jay Slupesky

Reputation: 1913

It sounds like what you want is a push segue from Login Class to Image View Controller. In the Xcode storyboard you add a segue by ctrl-clicking in the source and dragging to the destination. Be sure to give the segue a name. Then in the Login Class you can call the UIViewController method performSegueWithIdentifier:sender:.

Oh, and you can get rid of the push segue from your navigation controller to Image View Controller.

Upvotes: 0

Related Questions