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];
}