Ios UIActionSheet单击第一个按钮时,第二个按钮被单击并变灰

Ios UIActionSheet单击第一个按钮时,第二个按钮被单击并变灰,ios,iphone,objective-c,uibutton,uiactionsheet,Ios,Iphone,Objective C,Uibutton,Uiactionsheet,当我尝试单击第一个按钮时,似乎单击了下一个按钮,但我无法单击右按钮。它总是选择下一步按钮 - (IBAction)choosePic:(UIButton *)sender { UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Pic" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTi

当我尝试单击第一个按钮时,似乎单击了下一个按钮,但我无法单击右按钮。它总是选择下一步按钮

- (IBAction)choosePic:(UIButton *)sender
{
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Pic" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take a Pic", @"Choose From Album", @"Choose From Library", nil];
    [sheet showInView:sender];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate  = self;
    imagePicker.allowsEditing = YES;

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        switch (buttonIndex) {
            case 0:
            {
                PBJViewController *pbj = [[PBJViewController alloc] init];
                pbj.delegate = self;
                [self.navigationController pushViewController:pbj animated:YES];
            }
                break;
            case 1:
                imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
                [self.navigationController presentViewController:imagePicker animated:YES completion:NULL];
                break;
            case 2:
                imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                [self.navigationController presentViewController:imagePicker animated:YES completion:NULL];
                break;
            case 3:

                break;
            }


    } else
    {
        switch (buttonIndex) {
            case 0:
                imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
                [self.navigationController presentViewController:imagePicker animated:YES completion:NULL];
                break;
            case 1:
                imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                [self.navigationController presentViewController:imagePicker animated:YES completion:NULL];
                break;
            case 2:

                break;
        }
    }
}

请分享您编写按钮选择代码的委托方法。如何在
UIActionSheet
委托
-didDismissWithButtonIndex:
中实现代码。您可以使用
buttonIndex==1
以后的按钮索引,而取消按钮索引为0,其余的按钮索引为1,2,3。