首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >与搜索栏的交互不能快速工作

与搜索栏的交互不能快速工作
EN

Stack Overflow用户
提问于 2018-05-28 08:30:38
回答 1查看 41关注 0票数 -1

我正在通过代码包括搜索栏,并使用以下代码启用交互,搜索栏将显示,但当我单击字段时,编辑功能未启用:

代码语言:javascript
复制
let searchTableViewController = storyboard?.instantiateViewController(withIdentifier: "SearchBarTableVC") as? SearchBarTableVC
    searchTableViewController?.handleMapSearchDelegate = self
    searchTableViewController?.mapView = self.mapView

    searchBarController = UISearchController(searchResultsController: searchTableVC)
    searchBarController?.searchResultsUpdater = searchTableVC

    let searchBar = searchBarController?.searchBar

    searchBar?.sizeToFit()
    searchBar?.placeholder = "Digite o local"
    searchBar?.tintColor = UIColor.red
    searchBar!.isUserInteractionEnabled = true

    searchBar?.backgroundColor = UIColor(named: "ColorTransparent")

    navigationItem.titleView = searchBarController?.searchBar

    searchBarController?.hidesNavigationBarDuringPresentation = false
    searchBarController?.dimsBackgroundDuringPresentation = true

    definesPresentationContext = true
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-28 08:39:08

如果您使用的是iOS 11,首选的方法是简单地编写:

navigationItem.searchController = searchController

就这样。您不必定位搜索栏或将其放在任何视图中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50557731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档