-4

I want to make the bottom button seen in the storyboard on the right to take the user to the signupstoryboard.storyboard/signupController seen on the left when the user taps on the button. How can that be done?

http://i.imgur.com/qzKIzdW.png

Error

{ - (IBAction)signupbutton:(id)sender; SignupController *signUpView = [self.storyboard instantiateViewControllerWithIdentifier:@"signup"]; [self presentViewController:signUpView animated:YES completion:nil]; }
  • By code: http://stackoverflow.com/questions/9896406/how-can-i-load-storyboard-programmatically-from-class – Larme Aug 26 '14 at 13:11
  • 3
    Don't post screenshots of code in a question. Just copy and past the code. I can barely read the code in that screenshot. – Fogmeister Aug 26 '14 at 13:13
  • @Larme How exactly does this help me? The dude doesn't pick a specific button to take him to a storyboard, he just names a storyboard to transition to another storyboard. I could use some help, I'm new on objective-c – Robert Van Gilder Aug 26 '14 at 13:19
  • 1
    YOU STRUCTURED THE METHOD ALL WRONG. – Infinity James Aug 26 '14 at 13:59
  • woaah dude.. woaaaaah dude aight. what's wrong with it? – Robert Van Gilder Aug 26 '14 at 14:00
  • `- (IBAction)signupbutton:(id)sender { SignUpController *signUpView = [self.storyboard instantiateViewControllerWithIdentifier:@"signup"]; [self presentViewController:signUpView animated:YES completion:nil]; }` – Infinity James Aug 26 '14 at 15:08
  • 1
    Replace your entire method starting from `{ - (IBAction)` with my version – Infinity James Aug 26 '14 at 15:11
  • @InfinityJames Thanks. This did not give me any errors. However it gives me Thread 1: Signal SIGABRT ..... libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) – Robert Van Gilder Aug 26 '14 at 15:22

2 Answers2

0

You'll have to do it by code.

- (IBAction)buttonTapped
{
    NSString *storyboardName = @"signupstoryboard";
    UIViewController *nextViewController = [[UIStoryboard storyboardWithName:storyboardName bundle:nil] instantiateInitialViewController];
    // if you are using a navigation controller to push it:
    [self.navigationController pushViewController:nextViewController animated:YES];
    // otherwise if you are presenting it modally:
    [self presentViewController:nextViewController animated:YES completion:nil]    
}
Infinity James
  • 4,667
  • 5
  • 23
  • 36
  • Yes, but I want it to go to the next view controller when I specifically click the bottom button which is named signupButton. Basically when I tap that, I want it to take me to the signup page which is a separate controller/storyboard – Robert Van Gilder Aug 26 '14 at 13:22
  • Yeah... hook up that button to the above method (switch the storyboard name with the actual name though obviously). – Infinity James Aug 26 '14 at 13:34
  • well here's my code and it gives me an error "expected expression" { - (IBAction)signupbutton:(id)sender; SignupController *signUpView = [self.storyboard instantiateViewControllerWithIdentifier:@"signup"]; [self presentViewController:signUpView animated:YES completion:nil]; } – Robert Van Gilder Aug 26 '14 at 13:35
  • Has the view controller actually got the Storyboard ID "signup"? – Infinity James Aug 26 '14 at 13:37
  • Have you debugged `storyboard` to check it is a valid object (and points to the correct storyboard)? – Infinity James Aug 26 '14 at 13:41
  • yeah, I have and it launches properly. But when I add the code above to the implementation, it says "expected expression" – Robert Van Gilder Aug 26 '14 at 13:48
  • Copy the full exception into a comment. – Infinity James Aug 26 '14 at 13:56
  • 1
    Your method is completely wrong. Look at my method and then yours and look at the structural differences, – Infinity James Aug 26 '14 at 14:01
  • yes bud, but the thing is that the error isn't at the part we have different. The error is at the -(IBAction)buttontapped! – Robert Van Gilder Aug 26 '14 at 14:02
0

In your .m (at the top)

#import "signupController.h"

In your button action method (Don't forget to set the storyboard id for your signupController as signup

- (IBAction)signupbutton:(id)sender
{
    SignupController *signUpView = [self.storyboard instantiateViewControllerWithIdentifier:@"signup"]; [self presentViewController:signUpView animated:YES completion:nil];
}

Thats it

Ty Lertwichaiworawit
  • 2,950
  • 2
  • 23
  • 42