【发布时间】:2013-08-22 18:46:22
【问题描述】:
根据以下说明,我将一个项目从使用 XIB 迁移到 Storyboard:https://stackoverflow.com/a/9708723/2604030 进展顺利。 但是我不能让 segues 以编程方式工作,我需要以这种方式使用它们,因为我有 2 个按钮链接到同一个 ViewController,但类型不同,希望你能从这张图片中理解为什么。
有2个难度模式按钮。我使用的代码:
`- (IBAction)btnNormalAct:(id)sender {
LevelController *wc = [[LevelController alloc] initWithNibName:@"LevelController" type:0];
[self.navigationController pushViewController:wc animated:YES];
}
- (IBAction)btnTimedAct:(id)sender {
LevelController *wc = [[LevelController alloc] initWithNibName:@"LevelController" type:1];
[self.navigationController pushViewController:wc animated:YES];
}`
这在我使用 XIB 时有效,而且我确信我在故事板的 VC 中正确链接了所有内容。如果我从情节提要中制作海格,它们就会起作用。但是我该如何处理这种情况。
另外:当从 XIB 更改为 Storyboard 时,这些台词好吗?这是进行此更改的正确方法(上面链接中显示的方式)吗?
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
}
【问题讨论】:
标签: iphone ios objective-c