[我在peoplePickerNavigationController中使用了UIActionSheet,并试图在UIActionSheetDelegate中使用presentModalViewController :,但失败了

问题描述 投票:0回答:1

情况如下:

在UIView A中设置一个按钮,按下该按钮后,它会将我们带到联系人选择器:

        ABPeoplePickerNavigationController *picker=[[ABPeoplePickerNavigationController alloc]init];
        picker.peoplePickerDelegate=self;
        [self presentModalViewController:picker animated:YES];
        [picker release];

并且我在选择器中使用了UIActionSheet,根据用户的选择转到不同的视图:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
    UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:nil otherButtonTitles:@"ViewB",@"ViewC",@"ViewD",@"ViewE",nil];
    [actionSheet showInView:picker.view];
    [actionSheet release];
        return NO;
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex==0)
        [self gotoViewB];
    else if(buttonIndex==1)
        [self gotoViewC];
    else if(buttonIndex==2)
        [self gotoViewD];
    else if(buttonIndex==3)
        [self gotoViewE];
}

-(void)gotoViewB{
    ViewB *bClass=[[ViewB alloc]init];
    [self presentModalViewController:bClass animated:YES];
    [bClass release];
}

但是我在联系人选择器视图中选择了一行之后,没有任何反应,因为选择器视图没有消失并且ViewB没有显示。我不知道这里出了什么问题,所以请帮忙:<

iphone uiactionsheet
1个回答
0
投票

您需要首先添加导航控制器,然后调用"presentModelViewController"

yourModelController =[[Yourmodelcontroller alloc]init];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController: yourModelController];
self.hidesBottomBarWhenPushed = YES;
[[self navigationController] presentModalViewController:controller animated:YES];
[controller release];
© www.soinside.com 2019 - 2024. All rights reserved.