Search code examples
objective-cfacebook-ios-sdk

FBLoginView several call of loginViewShowingLoggedInUser


I have 2 FBLoginView in 2 differents UIViewController : StartViewController and ProfilViewController.

When I login in the StartViewController, only the delegate method loginViewShowingLoggedInUser in this controller is called. So it's ok

But when i don't login in the StartView, and i login later in the ProfilView, both method loginViewShowingLoggedInUser are called : the one in StartViewController and the other one in ProfilViewController

In StartViewController :

- (void) loginViewShowingLoggedInUser:(FBLoginView *)loginView
{
   NSLog(@"start");
}

In ProfilViewController :

- (void) loginViewShowingLoggedInUser:(FBLoginView *)loginView
{
   NSLog(@"profile");
}

And when i loggin in ProfilViewController both methods are called and i have in console : start profile

How can i just called the method in the controller where i login and not in the others?

Thx a lot.


Solution

  • I just have the same issue and my solution was to have only one instance of the FBLoginView in the application, store it in singleton class like SSUtils or somewhere else from where you can obtain it later. After that you can place it on the view of the desired controller (in your case StartViewController or ProfilViewController) programmatically and don't forget to set a correct delegate.

    Hope it helps.