我遇到this问题,但答案对我没有帮助。我希望那些颜色导航栏在秒屏幕上会像第一个屏幕。 iOS 9或更高版本。
- (void) showAdressBookActionForIOSNineOrLater {
CNContactPickerViewController * newPicker = [[CNContactPickerViewController alloc] init];
newPicker.delegate = self;
NSDictionary *attributesNormal = [NSDictionary dictionaryWithObjectsAndKeys:
[UIFont appFont_Headline], NSFontAttributeName,
[UIColor appColor_white_0], NSForegroundColorAttributeName, nil];
//appColor_white_0 my custom color APP_RGBA(255.0f, 255.0f, 255.0f, 1.0f); appFont_Headline - [UIFont HelveticaNeueRegularFont:fontSize];
newPicker.navigationController.navigationBar.titleTextAttributes = attributesNormal;
newPicker.navigationController.navigationBar.translucent = NO;
newPicker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
newPicker.navigationController.navigationBar.tintColor = [UIColor appColor_white_0];
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setBarTintColor:[UIColor appColor_white_0]];
[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTitleTextAttributes:attributesNormal];
newPicker.predicateForEnablingContact = [NSPredicate predicateWithFormat:@"phoneNumbers.@count > 0"];
newPicker.predicateForSelectionOfContact = [NSPredicate predicateWithFormat:@"phoneNumbers.@count == 1"];
newPicker.predicateForSelectionOfProperty = [NSPredicate predicateWithFormat:@"key == phoneNumber"];
newPicker.displayedPropertyKeys = @[CNContactPhoneNumbersKey];
//
[[self currentNavigationController] presentViewController:newPicker animated:YES completion:nil];
并实施委托方法:
- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
CNContact *contact = contactProperty.contact;
NSString *identify = contactProperty.identifier;
NSString * selectedNumber = @"";
for (CNLabeledValue<CNPhoneNumber*>* number in contact.phoneNumbers) {
if ([number.identifier isEqualToString:identify]) {
selectedNumber = ((CNPhoneNumber *)number.value).stringValue;
}
} [self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker {
[self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
屏幕故事: