gpt4 book ai didi

swift - 第一行 tableview 部分覆盖

转载 作者:搜寻专家 更新时间:2023-11-01 07:02:30 24 4
gpt4 key购买 nike

我正在实现 Google Places API,当我按照他们提供的代码进行操作时,导航栏覆盖了第一行。我已经尝试过包含标题但也没有标题文本。在这两种情况下,该行的顶部都被覆盖了。我是否需要添加一些东西来向下移动表格 View ?

enter image description here

import UIKit
import GooglePlaces

class SearchGooglePlacesController: UIViewController {

var resultsViewController: GMSAutocompleteResultsViewController?
var searchController: UISearchController?
var resultView: UITextView?

override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Search for Resturant"
view.backgroundColor = .seGrey
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self

searchController = UISearchController(searchResultsController:
resultsViewController)
searchController?.searchResultsUpdater = resultsViewController

searchController?.searchBar.sizeToFit()
navigationItem.titleView = searchController?.searchBar

definesPresentationContext = true
searchController?.hidesNavigationBarDuringPresentation = false

}
}

extension SearchGooglePlacesController:
GMSAutocompleteResultsViewControllerDelegate {

func resultsController(_ resulstsController:
GMSAutocompleteResultsViewController, didAutocompleteWith place:
GMSPlace) {
searchController?.isActive = false

print("Place name: \(place.name)")
print("Place attributions: \(place.types)")
print("Place location: \(place.formattedAddress ?? "")")
let name = place.name
}

func resultsController(_ resultsController: GMSAutocompleteResultsViewController,
didFailAutocompleteWithError error: Error){
// TODO: handle the error.
print("Error: ", error.localizedDescription)
}

// Turn the network activity indicator on and off again.
func didRequestAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

func didUpdateAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}
}

最佳答案

我必须在 viewDidLoad 中使用它self.extendedLayoutIncludesOpaqueBars = true
self.edgesForExtendedLayout = .top

关于swift - 第一行 tableview 部分覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50298362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com