Why placeholder text jump upward little when first tap searchBar?


Why placeholder text jump upward little when first tap searchBar?



I put a searchBar in first cell in the UITableView (not in UITableView header!) :


firstCell.contentView.addSubview(searchController.searchBar)



and I canceled hide navigation bar when search happened :


searchController.hidesNavigationBarDuringPresentation = false



and full setup searchController code in below :


func setupSearchController(){

//custom Search Results Controller
let folderSearchVC = FolderSearchViewController()
searchController = UISearchController(searchResultsController: folderSearchVC)

//cancel hide NavigationBar
searchController.hidesNavigationBarDuringPresentation = false

searchController.searchResultsUpdater = folderSearchVC
searchBar = searchController.searchBar

searchBar.placeholder = "搜索习惯组"

firstCell.contentView.addSubview(searchBar)
}



But when I first activate the searchBar,the placeholder text will jump upward a little,only for the first time (demo in below GIF):



enter image description here



You can see in the demo gif ,when I first tap searchBar,the placeholder text jump upward a little,and follow tap is all OK!



my Q is how to forbid placeholder text to jump upward ???
thanks ;)









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages