FBSDKLoginManager无法在本机ios应用程序中打开登录对话框

时间:2015-06-11 04:19:59

标签: ios facebook

我是iPhone开发的新手,我想使用最新的facebook sdk 4从我原生的iOS简单应用程序登录facebook。我只想打开自定义UIButton点击的Facebook登录对话框,我的应用程序和我在我的按钮点击方法下面的代码。

- (IBAction)didTapLoginFaceBook:(id)sender {

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error) {
            // Process error

        NSLog(@"Unexpected login error: %@", error);
        NSString *alertMessage = error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?: @"There was a problem logging in. Please try again later.";
        NSString *alertTitle = error.userInfo[FBSDKErrorLocalizedTitleKey] ?: @"Oops";
        [[[UIAlertView alloc] initWithTitle:alertTitle
                                        message:alertMessage
                                       delegate:nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil] show];


        } else if (result.isCancelled) {
            // Handle cancellations
        } else {
            // If you ask for multiple permissions at once, you
            // should check if specific permissions missing
            if ([result.grantedPermissions containsObject:@"email"]) {
                // Do work
            }
        }
    }];


}

此代码的工作方式不同,但我想打开一个登录对话框表单自定义UIButton单击本机iOS应用程序。

所以,请提前通过一些代码建议正确的方法

1 个答案:

答案 0 :(得分:2)

Facebook使用Objective-C中的自定义按钮登录4.x

@Override
public void onConfigurationChanged(Configuration newConfig) {
    if(newConfig.orientation != myOrientation){
        // perform rotation-specific tasks
    }
    super.onConfigurationChanged(newConfig);
}

Facebook使用Swift中的自定义按钮登录4.x

wordList = open(wordBank).readlines()
wordChosen = random.choice(wordList)
while len(wordChosen) < 5:
    continue
print (wordChosen)