使用Google Places API时发生错误“获取输出帧失败,状态8196”

时间:2018-12-30 05:40:37

标签: ios swift uitableview googleplacesautocomplete

我有一个searchController从Google Places API获取数据。我正在使用UITableView填充单元格,但是并未填充它们(由于上述错误,我认为是这样)

  • 我已经设置了所有代表
  • TableView正在重新加载数据
  • 请求已按预期在控制台中打印

根据我在S / OF上阅读的内容,这可能与单元格的注册有关-请参见下面的代码

TableView

func configureTableView() {
        tableView.delegate = self
        tableView.dataSource = self
        view.addSubview(tableView)
        tableView.anchor(top: view.topAnchor, left: view.leftAnchor, bottom: view.bottomAnchor, right: view.rightAnchor,
                         paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0,
                         width: 0, height: 0)
        tableView.tableFooterView = UIView()
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: recentSearchesCellIdentifier)
        tableView.register(ResultsCell.self, forCellReuseIdentifier: searchResultsCellIdentifier)
        tableView.keyboardDismissMode = .interactive
        tableView.backgroundColor = UIColor(red: 242/255, green: 242/255, blue: 243/255, alpha: 1)
    }

CellForItemAtIndexPath

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let recentSearchesCell = tableView.dequeueReusableCell(withIdentifier: recentSearchesCellIdentifier, for: indexPath)
    let searchResultsCell = tableView.dequeueReusableCell(withIdentifier: searchResultsCellIdentifier, for: indexPath) as! ResultsCell
    switch sections[indexPath.section].section {
    case .RecentSearches:
        recentSearchesCell.selectionStyle = .none
        let recentSearches = recentResults[indexPath.row]
        recentSearchesCell.textLabel?.text = recentSearches
        recentSearchesCell.detailTextLabel?.text = recentSearches
        return recentSearchesCell
    case .SearchResults:
        searchResultsCell.selectionStyle = .none
        let result = searchResults[indexPath.row]
        searchResultsCell.result = result
        return searchResultsCell
    }
}

单元格

class ResultsCell: UITableViewCell {

    var result: GMSAutocompletePrediction? {
        didSet {
            self.textLabel?.attributedText = result?.attributedPrimaryText
            self.detailTextLabel?.attributedText = result?.attributedSecondaryText
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }
}

0 个答案:

没有答案