我正在选择一个 Facebook 朋友。我想在启动 facebook 朋友选择器的文本字段中显示 facebook 朋友的名字。
谢谢!
此外,获取用户字符串名称和选择要发送对象的朋友之间有区别吗?因为这就是用户要做的事情。因此,我需要显示用户名的字符串值,但我还必须将对象与该用户相关联。
-(IBAction)cancelList;
-(IBAction)submitList;
-(IBAction)datePicker;
@property (strong, nonatomic) IBOutlet UITextField *listFieldText;
@property (strong, nonatomic) IBOutlet UITextField *dateFieldText;
@property (strong, nonatomic) IBOutlet UITextField *wallPostText;
@property (strong, nonatomic) IBOutlet UITextField *friendsName;
@property (retain, nonatomic) UIDatePicker *pick;
@property (strong, nonatomic) UIImage *profilePic;
@property (retain, nonatomic) PF_FBFriendPickerViewController *friendPickerController;
执行:
- (void)textFieldDidBeginEditing:(UITextField *)sender
{
sender.delegate = self;
if([sender isEqual:dateFieldText])
{
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
initWithTitle:@"Save Date"
style:UIBarButtonItemStyleDone
target:self
action:@selector(datePicker)];
self.navigationItem.rightBarButtonItem = doneButton;
pick = [[UIDatePicker alloc] init];
[pick setFrame:CGRectMake(0,200,320,120)];
//[pick addTarget:self action:@selector(done) forControlEvents:UIControlEventValueChanged];
dateFieldText.delegate = self;
dateFieldText.inputView = pick;
}
else if ([sender isEqual:friendsName])
{
NSLog(@"Pick a friend!");
if (self.friendPickerController == nil) {
// Create friend picker, and get data loaded into it.
self.friendPickerController = [[PF_FBFriendPickerViewController alloc] init];
self.friendPickerController.title = @"Select Friends";
self.friendPickerController.delegate = self;
self.friendPickerController.allowsMultipleSelection = NO;
}
[self.friendPickerController loadData];
[self.friendPickerController clearSelection];
[self presentModalViewController:self.friendPickerController animated:YES];
}
else{
UIBarButtonItem *submitButton = [[UIBarButtonItem alloc]
initWithTitle:@"Done"
style:UIBarButtonItemStyleDone
target:self
action:@selector(submitList)]; //change this
self.navigationItem.rightBarButtonItem = submitButton;
}
}
-(void)updateFriendTextField:(NSString*)subtitle
{
friendsName.text = subtitle;
}
/*
-(void)updateSelections
{
NSString* friendsSubtitle = @"Selected friends";
id<PF_FBGraphUser> friend = [self.selectedFriends objectAtIndex:0];
friendsSubtitle = friend.name;
[self updateFriendTextField:friendsSubtitle];
//[self handlePickerDone];
}
*/
-(void)friendPickerViewControllerDataDidChange:(PF_FBFriendPickerViewController *)friendPicker {
NSLog(@"Current friend selections: %@", friendPicker.selection);
}
- (void)dealloc
{
friendPickerController.delegate = nil;
}
- (void)facebookViewControllerCancelWasPressed:(id)sender
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
NSLog(@"Friend selection cancelled.");
//[self handlePickerDone];
}
- (void)facebookViewControllerDoneWasPressed:(id)sender
{
NSLog(@"Done was pressed.");
//[self updateSelections];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}