1

我需要制作一个按钮(“继续”)来打开另一个 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];
}

}

4

1 回答 1

1

你为什么不执行一个呈现转场来调出你的下一个视图控制器?转到您的故事板并创建一个指向新视图控制器的 segue。您需要创建一个模态转场并将其命名为独特的。

为此,将所有必要的视图控制器添加到情节提要中,然后右键单击呈现的视图控制器。创建模态segue呈现。

然后从你的代码里面你可以简单地输入:

 if(buttonIndex == 0)
      [self performSegueWithIdentifier:@"openView" sender:self];

解雇更容易!

   [self dismissModalViewControllerAnimated:YES];
于 2013-06-21T15:55:00.330 回答