小编Vim*_*.M.的帖子

根据单元格增加TableView高度

我需要UITableView根据UITableViewCell内容大小增加高度.我正在使用自定义Google自动完成功能.我有一个UITextField.当我输入一个字母时,UITextField它将调用shouldChangeCharactersIn范围委托方法.

在该方法中,我将向Google AutoComplete API发送动态请求以获取预测结果.

func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {

    if tableView.numberOfRows(inSection: 0) > 0
    {

    let newLength = (textField.text?.characters.count)! + string.characters.count - range.length
    let enteredString = (textField.text! as NSString).replacingCharacters(in: range, with:string)

    if newLength == 0 {
        tableView.isHidden = true
    }

    if newLength > 0
    {
        address.removeAll()
        self.tableView.isHidden = false

        GetMethod("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=\(enteredString)&key=MYAPIKEY", completion: { (resultDict) in

            let resultArray = resultDict.object(forKey: "predictions")! as! NSArray

            print(resultArray.count) …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios swift

7
推荐指数
2
解决办法
8542
查看次数

如何在使用苹果功能登录时使用“用户”参数获取电子邮件、姓名等用户信息?

Apple 在 WWDC19 上在 iOS 13 和更高版本的 iOS 中引入了使用 Apple 登录功能。我已经在我的应用程序中实现了该功能。

当用户第一次对应用程序进行身份验证时,我们将在下面的委托方法中获取电子邮件、名称、用户、状态等身份验证信息。

func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { }
Run Code Online (Sandbox Code Playgroud)

一旦用户成功通过身份验证,Apple 将在 Apple 登录下的 iCloud 中维护应用程序信息。

同样,当用户尝试对同一个应用程序进行身份验证时,Apple 将返回 User、State 等。它不应返回名称和电子邮件信息。

有没有办法在上述委托方法中使用该用户参数获取用户的电子邮件和姓名。

ios swift apple-sign-in sign-in-with-apple

6
推荐指数
2
解决办法
5119
查看次数