【发布时间】:2012-04-25 03:24:58
【问题描述】:
我想要实现的是在单击警报视图按钮时转到另一个视图。我的警报视图在我的 loadingView 中,这个警报视图是从另一个名为 classA 的类中调用的。
这是在classA中的调用方式。
[LoadingViewController showError];
这是loadingView类的loadingView中的方法。
+ (void)showDestinationError{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Error"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
alert.tag = DEST_ERR;
[alert show];
}
按钮操作
+ (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag = DEST_ERR){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UINavigationController *secondView = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];
secondView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[secondView presentModalViewController:secondView animated:YES];
}
}
这给了我一个错误。 '应用程序试图在其自身上呈现模态视图控制器。呈现控制器是 UINavigationController:..
注意:我的方法是'+'
【问题讨论】:
-
您可以通过访问视图控制器 self.storyboard 上的属性来访问当前故事板,然后执行 segue 或类似的操作
标签: xcode viewcontroller alertview