我需要创建一个按钮(“继续”),打开另一个UiView / Page。我对发展很陌生。虽然有人可以请我走吧?谢谢你们,你们对我有很大的帮助。
代码:
- (IBAction)OpenActionSheetButton:(id)sender {
UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:@"There is no going back, are you sure???" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Continue" otherButtonTitles:nil, nil];
[actionsheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboardViewIdentifier"];
//storyboardViewIdentifier is the ViewController identifier you specify in the storyboard
//PUSH
[self.navigationController pushViewController:controller animated:YES];
//Modal
[self presentViewController:controller animated:YES completion:Nil];
}
}
这就是我对你的代码所做的:
- (IBAction)OpenActionSheetButton:(id)sender {
UIActionSheet *actionsheet = [[UIActionSheet alloc]initWithTitle:@"There is no going back, are you sure???" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Continue" otherButtonTitles:nil, nil];
[actionsheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
if(buttonIndex == 0)
[self performSegueWithIdentifier:@"openView" sender:self];
UIViewController *controller = [self.storyboard
instantiateViewControllerWithIdentifier:@"storyboardViewIdentifier"];
//storyboardViewIdentifier is the ViewController identifier you specify in the storyboard
//PUSH
[self.navigationController pushViewController:controller animated:YES];
//Modal
[self presentViewController:controller animated:YES completion:Nil];
}
}
答案 0 :(得分:1)
为什么不执行提示segue来启动下一个视图控制器?转到故事板并创建指向新视图控制器的segue。您需要创建一个模态segue并将其命名为独特的东西。
要执行此操作,请将所有必要的视图控制器添加到故事板,然后右键单击视图控制器演示。创建模态segue呈现。
然后从你的代码中你可以简单地把:
if(buttonIndex == 0)
[self performSegueWithIdentifier:@"openView" sender:self];
解雇更容易!
[self dismissModalViewControllerAnimated:YES];