首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在peoplePickerNavigationController中使用了UIActionSheet,并尝试在UIActionSheetDelegate中使用presentModalViewController:,但失败了

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

Stack Overflow用户
提问于 2011-07-22 18:35:19
回答 1查看 468关注 0票数 0

情况是这样的:

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

代码语言:javascript
复制
        ABPeoplePickerNavigationController *picker=[[ABPeoplePickerNavigationController alloc]init];
        picker.peoplePickerDelegate=self;
        [self presentModalViewController:picker animated:YES];
        [picker release];

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

代码语言:javascript
复制
- (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也没有显示。我不知道这里出了什么问题,所以请帮我一下:<

EN

回答 1

Stack Overflow用户

发布于 2011-07-22 19:10:09

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

代码语言:javascript
复制
yourModelController =[[Yourmodelcontroller alloc]init];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController: yourModelController];
self.hidesBottomBarWhenPushed = YES;
[[self navigationController] presentModalViewController:controller animated:YES];
[controller release];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6788763

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档