ios - 我的搜索控制器没有收到任何响应
问题描述
class FirstViewController: UIViewController {
var resultsViewController: GMSAutocompleteResultsViewController?
var searchController: UISearchController?
var resultView: UITextView?
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
view = mapView
// Creates a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
resultsViewController = GMSAutocompleteResultsViewController()
resultsViewController?.delegate = self
searchController = UISearchController(searchResultsController: resultsViewController)
searchController?.searchResultsUpdater = resultsViewController
let subView = UIView(frame: CGRect(x: 0, y: 65.0, width: 350.0, height: 45.0))
subView.addSubview((searchController?.searchBar)!)
view.addSubview(subView)
view.
searchController?.searchBar.sizeToFit()
searchController?.hidesNavigationBarDuringPresentation = false
definesPresentationContext = true
}
}
当我点击我的搜索栏时,它不起作用,它被冻结了。
解决方案
推荐阅读
- javascript - 使用 fetch() 在服务器上发送 .zip 文件时遇到问题
- python - 执行用于抓取的 Python 代码时出现问题
- python - 使用python从.docx文件中的表中获取文本
- angular - typeError:无法解构“object null”的属性“init”,因为它在 ngx 电子图表中为 null
- node.js - 存储 MongoClient.connect()
- swift - SwiftUI - 带有坐标的 .position 修饰符
- java - 带有 Windows 10 zip 文件的 Java 14 无效 CEN 标头(错误压缩方法:9)
- flutter - 当使用 setState() 更改 URL 时,如何让 Image.network 更新?
- javascript - 如何使用 XHRWebRequest 在 URL 上上传文件?
- c++ - OpenGL着色器和绘图命令的共存