如何使actionsheet转到另一个视图?Xcode,小问题,,,

z3yyvxxp  于 2023-05-23  发布在  其他
关注(0)|答案(2)|浏览(74)

我试图为另一个按钮制作actionsheet,但我得到两个错误:"No visible @interface for 'UIstoryboard' declares the selector 'InitiateViewControll:'和,"No visible @interface for SWViewController' declares the selector 'presentViewController:animated:'我给这个代码,所以有没有什么名字,我需要命名,使这个代码适合我的代码?我正在努力学习我是一个noob对不起:(以下是我到目前为止拥有的代码:

- (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 instantiateViewControll:@"storyboardViewName"];
        //Push
        [self.navigationController pushViewController:controller animated:YES];
        //Modal
        [self presentViewController:controller animated:YES];

    }

}

请帮助大家?

7vhp5slm

7vhp5slm1#

试用此代码。. SWViewController必须有导航控制器

-(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];
        }
    }
4uqofj5v

4uqofj5v2#

试试这个。对我很有效:

if(buttonIndex == 0) 
 {
 NSString * storyboardName = @"Main";
 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
 Paypal_ViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"Paypal_ViewController"];
 [self presentViewController:vc animated:YES completion:nil];
 }

相关问题