我正试图在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];
}
我得到了这个结果:
是的,联系人正坐在标签内,但现在有问题:
现在邪恶在哪里?
答案 0 :(得分:2)
您正在tabBarController之上呈现视图控制器,这就是隐藏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(子类)可能会导致一些非常奇怪的用户体验。此外,您必须将表视图底部插入(与tabBar的高度相同,通常为49px)设置为ABPeoplePickerNavigationController,以便查看表的最后一个条目。
ABPeoplePickerNavigationController有一个navigationBar属性,你可以将它的色调颜色改为(例如)黑色:
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.navigationBar.tintColor = [UIColor blackColor];
我怀疑您是否能够在应用审批流程中删除取消按钮而不会被拒绝。此外,ABPeoplePickerNavigationController中没有取消按钮的属性,因此您必须从例如获取引用。浏览navigationBar子视图。
答案 1 :(得分:1)
我希望你现在想出来,但这是因为模态视图控制器被添加到活动窗口的顶部。这就是它超越标签栏顶部的原因。 UIViewController
还有一个方法presentViewController:animated:completion:
可能会更适合您。如果使用modalTransitionStyle
属性指定动画的类型,则会有一些动画选项。祝你好运(如果它还是一个问题)。