2

我目前正在使用 Swift 开发一个 iOS 应用程序,我已经下载了 facebook sdk login 并且我也很熟悉它。另一方面,我需要制作自定义表格视图,所以我下载了 Eureka 框架来执行此操作。

我有一个表格,要求用户提供信息以注册一个新帐户,问题是我需要在表格视图顶部有一个 facebook 登录选项,但我还没有找到完成此操作的方法。由于 Eureka 表视图是以编程方式添加的,因此可以在情节提要中看到它,因此我需要找到一种方法并添加登录按钮。有谁知道如何做到这一点?谢谢

这是我的表格代码:

private func addLoginForm() {
        self.form +++ Section()
            <<< TextRow() { $0.placeholder = "Name"
                $0.tag = "name"
            }
            +++ Section()
            <<< TextRow() { $0.placeholder = "Email"
                $0.tag = "email"
            }
            +++ Section()
            <<< PhoneRow() {$0.placeholder = "Phone"
                $0.tag = "phone"
            }
            +++ Section()
            <<< PasswordRow() { $0.placeholder = "Password"
                $0.tag = "password"
            }
            +++ Section()
            <<< ButtonRow() {
                $0.title = "Login"
                $0.onCellSelection { cell, row in

                    self.evaluate()

                    }.cellSetup({ (cell, row) in
                        cell.backgroundColor = UIColor(red: 114.0/255, green: 3.0/255, blue: 194.0/255, alpha: 1.0)
                        cell.tintColor = UIColor.whiteColor()
                        row.cell.height = {
                            return  65
                        }
                    })
        }

    }
4

2 回答 2

1

我通过在如下形式的部分标题中添加 facebook 登录来创建解决方案:

   form  +++ Section()
            {
                var header = HeaderFooterView<FBSDKLoginButton>(HeaderFooterProvider.Class)
                header.onSetupView = { (view: FBSDKLoginButton, section: Section) -> Void in
                     view.readPermissions = ["public_profile","email","user_friends"]
                     view.delegate = self
                }

                $0.header = header
        }

你还需要导入 FBSDKLoginKit 和 FBSDKCoreKit

于 2016-05-29T02:24:11.630 回答
0

您可以将标题添加到表视图而不是部分。

override func viewDidLoad() {
    super.viewDidLoad() 

    ...

    if let tableView = tableView {
        tableView.tableHeaderView = yourFBHeaderView
    }

    ...
}
于 2016-06-14T09:36:23.650 回答