嗨,我在 Xib 文件中的 Xcode 4.6 上的应用程序中使用了类似的功能,但单击 facebook 时未登录。而在另一边,当我在故事板的另一个应用程序中登录时,它是登录。如果有人知道,请指导我。
- (id)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
_facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.facebookLikeView.href = [NSURL URLWithString:@"http://sis.uol.edu.pk/sis/MainForms/login.aspx"];
self.facebookLikeView.layout = @"button_count";
self.facebookLikeView.showFaces = NO;
// self.facebookLikeView.alpha = 1;
[self.facebookLikeView load];
facebookLikeView.delegate = self;
}
#pragma mark FBSessionDelegate methods
- (void)fbDidLogin {
self.facebookLikeView.alpha = 1;
[self.facebookLikeView load];
}
- (void)fbDidLogout {
self.facebookLikeView.alpha = 1;
[self.facebookLikeView load];
}
#pragma mark FacebookLikeViewDelegate methods
- (void)facebookLikeViewRequiresLogin:(FacebookLikeView *)aFacebookLikeView {
[_facebook authorize:[NSArray array]];
}
- (void)facebookLikeViewDidRender:(FacebookLikeView *)aFacebookLikeView {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDelay:0.5];
self.facebookLikeView.alpha = 1;
[UIView commitAnimations];
}
- (void)facebookLikeViewDidLike:(FacebookLikeView *)aFacebookLikeView {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Liked"
message:@"You liked my app. Thanks!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] ;
[alert show];
}
- (void)facebookLikeViewDidUnlike:(FacebookLikeView *)aFacebookLikeView {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unliked"
message:@"You unliked my app ."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] ;
[alert show];
}