class PlaceSelectorViewController: UIViewController, GMSAutocompleteResultsViewControllerDelegate, UISearchBarDelegate, UISearchControllerDelegate {我班上有UISearchBarDelegate
searchController?.searchBar.delegate = self我把代表设置为Self。
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
stopHighlight()
}但是这个代表电话不起作用
发布于 2017-06-29 17:22:28
您需要一个用于outleet的UISearchBar (假设您正在使用Storyboard,这非常简单,只需通过助理编辑器拖放)。这就是你要加入的代表。如果您是以编程方式构建的,那么这个变量就是要分配给委托的变量。
下面是构建的童话板的示例代码
@IBOutlet weak var searchBar: UISearchBar! (您必须在右边看到一个填充的圆圈,否则在Storyboard和这个插座之间没有链接)
..。
override func viewDidLoad() { super.viewDidLoad() searchBar.delegate = self }
https://stackoverflow.com/questions/43832830
复制相似问题