iPhone:ABPeoplePickerNavigationController赢得';无法在UITabBarController中正确显示

iPhone:ABPeoplePickerNavigationController赢得';无法在UITabBarController中正确显示,iphone,objective-c,ios,uitabbarcontroller,Iphone,Objective C,Ios,Uitabbarcontroller,我正试图在UITabBarController中显示iPhone联系人簿中的联系人。我走了这么远: - (void)contacts { ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init]; // place the delegate of the picker to the controller picker.peoplePickerDelegate =

我正试图在UITabBarController中显示iPhone联系人簿中的联系人。我走了这么远:

- (void)contacts 
{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
// place the delegate of the picker to the controller
picker.peoplePickerDelegate = self;

CGRect newFrame = self.tabBarController.view.frame;
newFrame.size.height = newFrame.size.height - 49;
picker.view.frame = newFrame;
[picker setAccessibilityViewIsModal:YES];
// showing the picker
[self.tabBarController presentModalViewController:picker animated:NO];
}
电话:

-(void)viewWillAppear:(BOOL)animated
{
   [self contacts];
}
因此,我得到以下结果:

  • 我看不到标签
  • 我的标签样式是黑色的,但选择器是蓝色的
  • 这是取消按钮
  • 如何使选项卡可见,使样式变黑,并摆脱取消按钮

    先谢谢你

    编辑:

    更改方法后:

    -(void)contacts
    {
       ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    picker.navigationBar.tintColor=[UIColor blackColor];
    // Display only a person's phone, email, and birthdate
    NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], nil];
    picker.displayedProperties = displayedItems;
    // Show the picker
    picker.navigationBar.hidden=YES;
    CGRect newFrame = picker.view.frame;
    newFrame.size.height = newFrame.size.height - 49;
    picker.view.frame = newFrame;
    
    [self.tabBarController.view addSubview:picker.view];
    
    }
    
    我得到了这个结果:

    是的,联系人位于选项卡内,但现在出现问题:

  • 当我用contacts触摸tableView时,contacts完全消失了
  • 当我切换选项卡时,“联系人”视图不会消失,我可以在所有选项卡中看到它
  • UISearchbar的一半保持隐藏状态

  • 邪恶现在在哪里?

    您将视图控制器显示在tabBar控制器的顶部,这就是tabBar被隐藏的原因。尝试以下方法:

    UIViewController *controller = [tabBarController.viewControllers objectAtIndex:0]; // Let's assume this is the desired view controller that should display the ABPeoplePickerNavigationController
    [controller presentModalViewController:picker animated:NO];
    
    请记住,在tabbar控制器下面显示UIViewController(子类)可能会导致一些非常奇怪的用户体验。此外,为了查看表格的最后一个条目,您必须将表格视图底部插图(与选项卡栏的高度相同,通常为49px)设置到ABPeoplePickerNavigationController

    ABPeoplePickerNavigationController具有navigationBar属性,您可以将其色调更改为(例如)黑色:


    我怀疑您是否能够删除取消按钮而不会在应用程序审批流程中被拒绝。此外,ABPeoplePickerNavigationController中没有cancel按钮的属性,因此您必须从导航栏子视图中获取引用。

    我希望您现在已经解决了这个问题,但这是因为在活动窗口的顶部添加了一个模态视图控制器。这就是为什么它会出现在选项卡栏的顶部
    UIViewController
    还有一个方法
    presentViewController:animated:completion:
    ,可能对您更有效。如果使用
    modalTransitionStyle
    属性指定动画类型,则有一些动画选项。祝你好运(如果这仍然是一个问题)。

    嗨。您是否将此视图控制器嵌入到序列图像板中的选项卡栏控制器中?您的表视图委托和数据源方法是什么样子的?是的,我已将此UIViewController嵌入到脚本中的UIAbbarController中。此特定选项卡栏链接到没有任何UITableView的UIViewController。在我的设备上运行时,我可以看到联系人。唯一的问题是没有选项卡,该死的取消按钮和错误的样式。我在这个选项卡中没有任何表视图,只有uiview。我只是让它成为picker。navigationBarHidden=YES;不管怎样,它只是把酒吧的颜色改成了黑色。搜索控制器和其他人都是默认颜色。“我怀疑你是否能够在应用程序审批过程中删除取消按钮而不被拒绝”。。。WhatsApp和Viber不使用取消按钮。我几乎找不到UITabBar应用程序中“取消”按钮的任何用途。我怀疑应用程序使用的是ABPeoplePickerNavigationController。另外,我没有说这是不可能的,但我认为您必须自己实现PeoplePickerViewController,方法是获取通讯簿用户并将其显示在您自己的UITableViewController中。也许此示例可以帮助您:您好。谢谢你的回复。我已经解决了这个问题。你的回答是对的。
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.navigationBar.tintColor = [UIColor blackColor];