【发布时间】:2013-12-12 16:50:27
【问题描述】:
我正在尝试在不使用 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 = 原点 ViewController ConsultasViewController / Consultas = 目标 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];
}
【问题讨论】:
-
您项目中的 .storyboard 文件的名称是什么?这是为 storyboardName 设置的名称。
-
已更新... Main.storyboard。但问题依然存在。
-
我认为 Wain 可能正在做点什么。尝试将方法处理程序更改为:-(void)consultaButton:(id)sender,或者按照他的建议,修改按钮操作代码。
-
工作安迪...非常感谢。最后一个问题......我怎样才能改变动画风格?
-
在调用 presentViewController 之前,设置演示样式。例如。 [控制器 setModalPresentationStyle:UIModalPresentationPageSheet];
标签: ios uistoryboardsegue