在iOS 8
FBFriendPickerViewController
中显示没有导航栏(在iOS 7
中,一切都很完美)。
我使用Facebook-iOS-SDK
v3.9.0,但我检查了最新的SDK并且也有相同的行为(我运行名为Scrumptious
的示例项目。)
代码:
- (void)pickFacebookFriends{
FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
ABAddressBookCreateWithOptions(NULL, NULL);
ABPersonSortOrdering sortOrdering = ABPersonGetSortOrdering();
ABPersonCompositeNameFormat nameFormat = ABPersonGetCompositeNameFormatForRecord(NULL);
friendPicker.sortOrdering = (sortOrdering == kABPersonSortByFirstName) ? FBFriendSortByFirstName : FBFriendSortByLastName;
friendPicker.displayOrdering = (nameFormat == kABPersonCompositeNameFormatFirstNameFirst) ? FBFriendDisplayByFirstName : FBFriendDisplayByLastName;
friendPicker.fieldsForRequest = [[NSSet alloc] initWithObjects:@"picture", nil];
[friendPicker loadData];
[friendPicker presentModallyFromViewController:self
animated:YES
handler:^(FBViewController *sender, BOOL donePressed) {
if (donePressed) {
if (friendPicker.selection.count > 0) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}}];
return;
[self presentViewController:friendPickerController animated:YES completion:nil];
}
这是截图:
答案 0 :(得分:3)
确保nav.bar不隐藏并按下。
[self.navigationController setNavigationBarHidden:NO animated:NO];
_taggableFriendPickerViewController = [FBTaggableFriendPickerViewController new];
[_taggableFriendPickerViewController loadData];
_taggableFriendPickerViewController.delegate = self;
[self.navigationController pushViewController:_taggableFriendPickerViewController animated:YES];
#pragma mark - FBViewControllerDelegate
///When you press on done button will call this method.
- (void)facebookViewControllerDoneWasPressed:(FBViewController *)sender
{
_arrayWithUsers = ((FBTaggableFriendPickerViewController *)sender).selection;
}
答案 1 :(得分:0)
您需要符合<FBViewControllerDelegate>
,然后符合:
FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
friendPicker.delegate = self;
ABAddressBookCreateWithOptions(NULL, NULL);
ABPersonSortOrdering sortOrdering = ABPersonGetSortOrdering();
ABPersonCompositeNameFormat nameFormat = ABPersonGetCompositeNameFormatForRecord(NULL);
friendPicker.sortOrdering = (sortOrdering == kABPersonSortByFirstName) ? FBFriendSortByFirstName : FBFriendSortByLastName;
friendPicker.displayOrdering = (nameFormat == kABPersonCompositeNameFormatFirstNameFirst) ? FBFriendDisplayByFirstName : FBFriendDisplayByLastName;
friendPicker.fieldsForRequest = [[NSSet alloc] initWithObjects:@"picture", nil];
[friendPicker loadData];
UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:friendPicker];
[self presentViewController:nc animated:YES completion:nil];
- (void)facebookViewControllerDoneWasPressed:(id)sender{
NSLog(@"%s",__PRETTY_FUNCTION__);
FBFriendPickerViewController *friendPicker = sender;
NSLog(friendPicker.selection.description);
}
结果是: