模态viewController中的IOS FacebooSDK 3.0 FBLoginVIew

Liz*_*ard 7 objective-c ios facebook-ios-sdk

我在rightBarButtonItem上显示模态视图控制器.我在此控制器中使用FbLoginView,如示例ios-Facebook SDK 3.0错误5发布状态更新时.

但我不能多次显示模态视图控制器.我试图在ViewDidUnload上发布FBLoginView但它总是崩溃第二次尝试打开模态视图控制器.

EES*_*EES 5

得到了同样的问题并且已经处理了几天.最后这是我的解决方案:

if (!FBSession.activeSession.isOpen) {
    theLoginView = [[FBLoginView alloc] init];
    theLoginView.frame = CGRectOffset(theLoginView.frame,
                                      ([[UIScreen mainScreen] bounds].size.width-theLoginView.frame.size.width)/2,
                                      ([[UIScreen mainScreen] bounds].size.height-theLoginView.frame.size.height)/2 -50);
    theLoginView.delegate = self;
    [self.view addSubview:theLoginView];
    [theLoginView sizeToFit];
}  
//Only close the session when application is terminating, this will save the token information:
- (void)applicationWillTerminate:(UIApplication *)application {
    [FBSession.activeSession close];
}  

//And keep the FBSession within the app until the user want to logout:
[FBSession.activeSession closeAndClearTokenInformation];
Run Code Online (Sandbox Code Playgroud)

现在对我来说它的工作完全没问题.希望这有帮助.


Han*_*tok 1

我有同样的问题。尝试添加这样的内容:

if(!yourFBLoginView)
{
    yourFBLoginView = [FBLoginView alloc] init...];
}
Run Code Online (Sandbox Code Playgroud)

和/或当您关闭 modalViewController 时,不要忘记关闭活动会话。

if ([[FBSession activeSession] isOpen])
{
    [[FBSession activeSession] close];
} 
Run Code Online (Sandbox Code Playgroud)