喜欢 iOS 应用程序中的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4087660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:00:32  来源:igfitidea点击:

Like button in iOS application

iosfacebookfacebook-graph-apifacebook-likefacebook-ios-sdk

提问by iKiR

Does anybody know how to place Facebook "like" button into iOS application? I've tried the method described in this blog post. But I do not really like this method, because its ugly Login dialog. And, what is more important, it makes user login twice. For example, user wants post a message to his wall if he isn't logged in I call standard FBLoginDialog, after that user posted a message he may want push "like" button and he have to login again - it is really bad user experience.

有人知道如何将 Facebook 的“赞”按钮放入 iOS 应用程序中吗?我已经尝试了这篇博文中描述的方法。但我不太喜欢这种方法,因为它丑陋的登录对话框。而且,更重要的是,它使用户登录两次。例如,如果用户没有登录,他想在他的墙上发布一条消息,我调用标准的 FBLoginDialog,在该用户发布一条消息后,他可能想要按下“喜欢”按钮,他必须再次登录 - 这真的是很糟糕的用户体验.

How to be? How can I give user "like" feature in my iOS app?

怎样成为?如何在我的 iOS 应用程序中为用户提供“喜欢”功能?

回答by Nathan Totten

That is actually the only way to do it. There is no special iOS like button. However, the good news is that just today Facebook announced single sign in support for mobile apps. This should remove some of the burden the user faces to log in to facebook.

这实际上是唯一的方法。没有像 iOS 那样的特殊按钮。然而,好消息是,就在今天,Facebook 宣布了对移动应用程序的单点登录支持。这应该会减轻用户登录 Facebook 所面临的一些负担。

回答by Oded Ben Dov

It seems there is an agreement on not being able to do this. This questionshows you can, as does the FB Graph API documentation:

似乎就无法做到这一点达成了一致。这个问题表明你可以,就像FB Graph API 文档一样

You can comment on or like any object that has a /comments or /likes connection by posting to https://graph.facebook.com/OBJECT_ID/commentsand https://graph.facebook.com/OBJECT_ID/likes, respectively.

您可以通过分别发布到https://graph.facebook.com/OBJECT_ID/commentshttps://graph.facebook.com/OBJECT_ID/likes来评论或喜欢任何具有 /comments 或 /likes 连接的对象。

Unfortunately, according to this questionyou can't like a page.

不幸的是,根据这个问题,你不能喜欢一个页面。

回答by bkaid

The only way supported by Facebook on any platform (web, mobile, etc) is from their iFrame code. From iOS, that means embedding a UIWebView into your application with the iFrame code. Note that it does require them to login via Safari.

Facebook 在任何平台(网络、移动等)上支持的唯一方式是来自他们的 iFrame 代码。在 iOS 中,这意味着使用 iFrame 代码将 UIWebView 嵌入到您的应用程序中。请注意,它确实要求他们通过 Safari 登录。

回答by Noam

I like using ShareKit: http://www.getsharekit.com/

我喜欢使用 ShareKit:http: //www.getsharekit.com/

It's not exactly what you're looking for, but still...

这不完全是你要找的东西,但仍然......

回答by Pavan Sisode

- (void)addLikeButton{
[FBSettings enableBetaFeature:TRUE];
[FBSettings enablePlatformCompatibility:NO];
 _like = [[FBLikeControl alloc] init];
_like.frame = CGRectMake(60,12,200,33);
_like.likeControlAuxiliaryPosition = FBLikeControlAuxiliaryPositionInline;
_like.likeControlHorizontalAlignment = FBLikeControlHorizontalAlignmentLeft;
_like.objectID = @"https://www.facebook.com/pages/Strana-Gapra/1377227779244834";
_like.likeControlStyle = FBLikeControlStyleStandard ;
[_like addTarget:self action:@selector(onSelect:) forControlEvents:UIControlEventValueChanged];
[self.likeView addSubview:_like];
[self performSelector:@selector(getLikeSubviews) withObject:nil afterDelay:0.6];

}

}