开发者

Facebook iOS problems callbacks etc

I integrated the facebook ios sdk into my application. When I first did this it was connected to my ONLY ViewController class. So it worked just like the demo. It also DID work. I was able to post to ever开发者_JAVA技巧ything etc. My app delegate has the correct connect URL stuff in it etc..

The problem came when I changed my app to have a different main screen and the last screen has the facebook connection info. So now my App Delegate has the function:

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
   SocialView *socialView = [[SocialView alloc] init];
   return [[socialView facebook] handleOpenURL:url];
}

Due to this change my facebook variable is always null when returning from the login and the didLogin never gets called. I'm assuming this is because every time it returns the view is being recreated and the facebook var is re-inited as well.

What is a solution to this? Thanks for any and all help...

-d

Edit: Its worth noting that if I only had one view:

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
   return [[viewController facebook] handleOpenURL:url];
}

works fine..


David, you are right. The solution you are showing allocate the alternative view controller each time the authentication is finished and the app is back from facebook-connect. This way nothing can be saved.

Here's what you should do: assume your viewcontroller which handles facebook-connect is called facebookViewController, then the code you need is:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

return [[viewController.facebookViewController facebook] handleOpenURL:url]; 
}

Try and let me know if you got it :) Good Luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜