2

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.

4

2 回答 2

1

我只是有同样的问题,我的解决方案是在应用程序中只有一个 FBLoginView 实例,将其存储在像 SSUtils 这样的单例类中,或者以后可以从中获取它的其他地方。之后,您可以以编程方式将其放置在所需控制器(在您的情况下为 StartViewController 或 ProfilViewController)的视图上,并且不要忘记设置正确的委托。

希望能帮助到你。

于 2013-06-27T11:06:14.340 回答
0

将该实例作为属性保存在 appdelegate 中,并在 applicationDidFinishLaunchingWithOptions 中对其进行初始化。无论您想在哪里引用 appdelegate 的实例并对其进行子视图,将委托设置为 self。在 dealloc 中将委托设置为 nil 并从超级视图中删除。不要释放它。

于 2013-08-17T15:26:41.000 回答