我正在選擇一個Facebook朋友。我想在啓動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];
}
可以簡化你的問題?它不清楚你的要求是什麼。 – Vijay 2013-03-13 06:52:08
基本上我可以啓動Facebook的朋友選擇器,並選擇朋友,但我不知道如何將數據[如用戶名等]傳遞到另一個視圖。朋友選取器從桌面視圖模式呈現。 – STANGMMX 2013-03-13 11:18:19
對於與IDE無關的問題,請勿使用[tag:xcode]標記。 – Undo 2013-03-14 00:28:09