在没有Segue的情况下调用Storyboard

时间:2013-12-12 16:50:27

标签: ios uistoryboardsegue

我试图在不使用Segue的情况下推送ViewController,但它无法正常工作。 我的按钮代码如下:

-(void)consultaButton
{
    NSString *storyboardName = @"Main";
    NSString *viewControllerID = @"Consultas";
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    EntradaViewController *controller = (EntradaViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
    [self presentViewController:controller animated:YES completion:nil];
}

EntradaViewController / Entrada = origin ViewController ConsultasViewController / Consultas = target ViewController

我有错误:

2013-12-12 14:42:51.519 JuntaComercial[14285:70b] -[EntradaViewController consultaButton:]: unrecognized selector sent to instance 0x9e51650

有人能给我一个帮助吗?我已经在使用Segue并且工作正常,但现在我需要在没有Segue的情况下做同样的事情。感谢名单!!


更新(工作代码):

-(void)consultaButton:(id)sender
{
    NSString *storyboardName = @"Main";
    NSString *viewControllerID = @"Consultas";
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    EntradaViewController *controller = (EntradaViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
    [controller setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:controller animated:YES completion:nil];
}

1 个答案:

答案 0 :(得分:1)

这似乎与storyboard / segue代码无关。相反,您有一个已配置操作的按钮,并且您已将操作设置为consultaButton:,但该方法实际上是consultaButton(请注意缺少冒号,因为该方法没有参数。因此,请更正方法签名或您设置为按钮操作的选择器。