Objective-C:如何制作一个按钮带你到另一个类/故事板

时间:2014-08-26 13:09:09

标签: objective-c storyboard

我想在右边的故事板中看到底部按钮,将用户带到用户点击按钮时左侧看到的signupstoryboard.storyboard / signupController。怎么办?

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

Error

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

2 个答案:

答案 0 :(得分:0)

你必须通过代码来完成。

- (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]    
}

答案 1 :(得分:0)

在你的.m(在顶部)

#import "signupController.h"

在您的按钮操作方法中(不要忘记将signupController的storyboard id设置为注册

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

多数民众赞成