NavigationController 和 FBConnect [iPhone SDK] 的问题
我在 AnotherViewController
[基于 NavigationController 项目] 上为我的应用程序实现了 Facbook 连接,在那里我有一些东西可以分享给 facebook 。所以当将此代码放在 viewDidLoad
上时。当用户使用 Push 动画转到 AnotherViewController 时。 我的 FBSession 似乎可以登录!我希望当用户选择按钮和 actionSheet 出现时,然后决定登录 facebook
- (void)actionSheet:(UIActionSheet *)menu didDismissWithButtonIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
session = [FBSession sessionForApplication:@"587421274743043f3177a2f86684e533" secret:@"d22ad909a2e670269edd4d4e79c61c2a" delegate:self];
[session resume];
if( session.isConnected )
{
[self showFBFeed];
}
else
{
FBLoginDialog* login = [[FBLoginDialog alloc] initWithSession:session];
[login show];
[login release];
}
break;
case 1:
[session logout];
break;
}
因此,当将该代码放在 viewDidUnload
方法上时,一切正常,但我的 facebook API 密钥和秘密不起作用!为什么 ? 如何解决我的问题? :| 谢谢 。
i implement Facbook connect for my app on the AnotherViewController
[based on NavigationController Project] , on there i have something to share to facebook . so when put this code on the viewDidLoad
. when user go to AnotherViewController with Push animation .
my FBSession appear to login !! i want when user select the button and actionSheet appear then decide to login to facebook
- (void)actionSheet:(UIActionSheet *)menu didDismissWithButtonIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
session = [FBSession sessionForApplication:@"587421274743043f3177a2f86684e533" secret:@"d22ad909a2e670269edd4d4e79c61c2a" delegate:self];
[session resume];
if( session.isConnected )
{
[self showFBFeed];
}
else
{
FBLoginDialog* login = [[FBLoginDialog alloc] initWithSession:session];
[login show];
[login release];
}
break;
case 1:
[session logout];
break;
}
So when put that code on the viewDidUnload
method everything works fine but my facebook API Key and secret doesn't work !!! why ?
How could solve my prablem ? :|
Thank you .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不明白你在做什么。
viewDidLoad
方法在视图控制器的视图加载并放置在屏幕上之前被调用。通过将上述代码放入其中,您将自动进行 Facebook 登录。如果您希望当用户单击操作表中的按钮时发生 facebook 登录,那么您应该从操作表的委托方法运行上述代码。
另外,在上面的代码中,当用户已经登录和没有会话时,您都会显示 facebook 登录屏幕。这完全没有意义。
I don't think you understand what you are doing. The
viewDidLoad
method is called before your view controller's view is loaded and put on the screen. By putting the above code in there you will aways automatically do a facebook login.If you want the facebook login to happen when the user clicks a button in your action sheet then you should run the above code from the action sheet's delegate method.
Also, in the above code you show the facebook login screen both when the user was already logged in and when there is no session. That makes no sense at all.