要访问GMSautocompleteVIEwController搜索栏:
let vIEws = gmsautoCompleteVIEwController.vIEw.subvIEwslet subvIEwsOfSubvIEw = vIEws.first!.subvIEwslet subOfNavTransitionVIEw = subvIEwsOfSubvIEw[1].subvIEwslet subOfContentVIEw = subOfNavTransitionVIEw[2].subvIEws let searchbar = subOfContentVIEw[0] as! UISearchbar
然后设置文本并自动搜索:
searchbar.text = "Your address"searchbar.delegate?.searchbar?(searchbar,textDIDChange: "Your address") // This performs the automatic searching.
我发现在尝试从内部设置文本时收到了EXC_BAD_ACCESS错误
dIDRequestautocompletePredictions(_ vIEwController:GMSautocompleteVIEwController).
所以我把这段代码放在我提供autoCompleteController的完成块中,它可以正常工作.
将它们组合在一起:
let gmsautoCompleteVIEwController = GMSautocompleteVIEwController()gmsautoCompleteVIEwController.delegate = selfpresent(gmsautoCompleteVIEwController,animated: true) { let vIEws = gmsautoCompleteVIEwController.vIEw.subvIEws let subvIEwsOfSubvIEw = vIEws.first!.subvIEws let subOfNavTransitionVIEw = subvIEwsOfSubvIEw[1].subvIEws let subOfContentVIEw = subOfNavTransitionVIEw[2].subvIEws let searchbar = subOfContentVIEw[0] as! UISearchbar searchbar.text = "Your address" searchbar.delegate?.searchbar?(searchbar,textDIDChange: "Your address")}
编辑:我发现这个解决方案似乎只适用于iOS 11.让searchbar = subOfContentVIEw [0]为!的UISearchbar将在iOS 10上失败,可能还会降低版本.
总结以上是内存溢出为你收集整理的swift – 如何在Google Place AutocompleteViewController中的GMSAutocompleteViewController中设置文本全部内容,希望文章能够帮你解决swift – 如何在Google Place AutocompleteViewController中的GMSAutocompleteViewController中设置文本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)