【发布时间】:2014-01-25 22:47:35
【问题描述】:
我有这个代码,目前它不能正常工作。当我单击按钮切换视图时,没有任何反应。我正在使用 Xcode 5 编程。如果您能提供帮助,我们将不胜感激。代码如下所示。
-(IBAction)RandomButton:(id)sender {
int randomviews = rand() % 2;
switch (randomviews) {
case 0:
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
@"Main.storyboard" bundle:[NSBundle mainBundle]];
Home *Next = [storyboard instantiateViewControllerWithIdentifier:@"SummerWinter"];
[self presentViewController:Next animated:YES completion:nil];
}
break;
case 1:
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
@"Main.storyboard" bundle:[NSBundle mainBundle]];
Home *Next = [storyboard instantiateViewControllerWithIdentifier:@"HiBye"];
[self presentViewController:Next animated:YES completion:nil];
}
break;
default:
break;
}
}
【问题讨论】:
标签: ios random view switch-statement