#import "whoViewController.h"
@interface whoViewController()
@property (nonatomic,strong) IBOutlet FBProfilePictureView *profilePictureView;
@property (nonatomic,strong) IBOutlet UILabel *nameLabel;
@property (nonatomic,strong) IBOutlet UILabel *statusLabel;
@end
上面應該將標籤添加到視圖中。Facebook登錄集成,以編程方式添加UILabel不起作用
@implementation whoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.readPermissions = @[@"basic_info", @"email", @"user_likes"];
loginView.center = self.view.center;
loginView.delegate = self;
[self.view addSubview:loginView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// This method will be called when the user information has been fetched
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
self.profilePictureView.profileID = user.id;
self.nameLabel.text = user.name;
}
// Implement the loginViewShowingLoggedInUser: delegate method to modify your app's UI for a
logged-in user experience
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
self.statusLabel.text = @"You're logged in as";
}
// Implement the loginViewShowingLoggedOutUser: delegate method to modify your app's UI for a
logged-out user experience
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
self.profilePictureView.profileID = nil;
self.nameLabel.text = @"";
self.statusLabel.text= @"You're not logged in!";
}
@end
我實現了上面的,因爲它在Facebook的教程說,但由於某種原因標籤不出現,爲什麼這可能是任何幫助嗎? 實際的登錄和登出工作,但標籤中的文本標籤和更改不起作用。
從以往的經驗來看,它應該工作,因爲邏輯看起來不錯。
你在廈門國際銀行/故事板添加這些標籤?他們連接嗎?委託方法是否被調用?你訂閱了委託協議嗎? –
您可能忘了將這些標籤從.storyboard /拖到您的視圖控制器中。xib文件並將它們連接到IBOutlets – Daniel
Facebook的iOS開發站點上的教程,它說這些標籤應該以編程方式工作,並且不需要將它們連接到故事板。與添加但在故事板上不可見的登錄視圖一樣。 –