0

我在下面的 handleCustomFBButton() 函数中将 UIcollectionViewCell 的值转换为 UIViewController 的参数类型时遇到问题。我认为设置我的代表和/或数据源有问题...感谢所有帮助!

import UIKit
import FBSDKLoginKit
import Firebase


class LoginCell: UICollectionViewCell, FBSDKLoginButtonDelegate {

    let logoImageView: UIImageView = {
        let image = UIImage(named: "me")
        let imageView = UIImageView(image: image)
        return imageView
    }()

    let emailTextField: LeftPaddedTextField = {
        let textField = LeftPaddedTextField()
        textField.placeholder = "Enter Email"
        textField.layer.borderColor = UIColor.lightGray.cgColor
        textField.layer.borderWidth = 1
        textField.keyboardType = .emailAddress
        return textField
    }()

    let passwordTextField: LeftPaddedTextField = {
        let textField = LeftPaddedTextField()
        textField.placeholder = "Enter Password"
        textField.layer.borderColor = UIColor.lightGray.cgColor
        textField.layer.borderWidth = 1
        textField.isSecureTextEntry = true
        return textField
    }()

    lazy var loginButton: UIButton = {
        let button = UIButton(type: .system)
        button.backgroundColor = .orange
        button.setTitle("Log in", for: .normal)
        button.setTitleColor(.white, for: .normal)
        button.addTarget(self, action: #selector(handleLogin), for: .touchUpInside)
        return button
    }()

    lazy var FBloginButton: UIButton = {
        let customButton = UIButton(type: .system)
        customButton.backgroundColor = UIColor.blue
        customButton.setTitle("Custom button here", for: .normal)
        customButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
        customButton.setTitleColor(.white, for: .normal)
        return customButton

        customButton.addTarget(self, action: #selector(handleCustomFBButton), for: .touchUpInside)
    }()

   // error happens on the from: self
    func handleCustomFBButton() {
        FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
            if err != nil {
                print("Custom FB Login Button Failed")
                return
            }
            self.showEmailAddress()
        }
    }
4

0 回答 0