i used UIActionSheet in peoplePickerNavigationController, and tried to presentModalViewController: in UIActionSheetDelegate, which failed
the situation is like:
theres a button in UIView A, which will lead us to the contact picker after pressing it:
ABPeoplePickerNavigationController *picker=[[ABPeoplePickerNavigationController alloc]init];
picker.peoplePickerDelegate=self;
[self presentModalViewController:picker animated:YES];
[picker release];
and i used an UIActionSheet in开发者_开发百科 the picker, to go to different Views according to the user's selection:
- (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];
}
but after i selected a row in the contact picker view, nothing happened as the picker view didnt disappear and ViewB didnt show. i dont know whats wrong here so plz lend me a hand :<
You need to add naviagation controller atfirst then call "presentModelViewController"
yourModelController =[[Yourmodelcontroller alloc]init];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController: yourModelController];
self.hidesBottomBarWhenPushed = YES;
[[self navigationController] presentModalViewController:controller animated:YES];
[controller release];
精彩评论