[英]Cancel button can't shown in GMSAutocompleteViewController
[英]GMSAutocompleteViewController remove the "cancel" button
試試這個你可以從 UISearchBar Delegate 方法禁用取消按鈕。
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
searchBar.setShowsCancelButton(false, animated: false)
}
func searchBarTextDidEndEditing(searchBar: UISearchBar) {
searchBar.setShowsCancelButton(false, animated: false)
}
如果您使用的是 CustomSearchBar
自定義搜索欄.swift
import UIKit
class CustomSearchBar: UISearchBar {
override func layoutSubviews() {
super.layoutSubviews()
setShowsCancelButton(false, animated: false)
}
}
GMSAutocompleteViewController 沒有任何“SearchBar”對象的引用來更改或隱藏“取消”按鈕。 您可以在 GMSAutocompleteViewController 內部檢查“SearchBar”是否沒有 IBOutlet。
您只能通過使用您自己的 SearchBar 創建自定義視圖控制器來隱藏取消按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.