[英]How to add a TextField above the TableView of a TableViewController
[英]How to add an image above tableview in TableViewController - Swift 3
我在帶有搜索欄的tableview控制器中有一個tableview。 我想以這種方式將圖像添加到它的頂部,使其像導航欄一樣,不會移動並實質上縮小了tableview。 我通常使用視圖控制器並將圖像添加到頂部,但似乎無法執行tableviewcontroller。 我嘗試添加UIView並調用
tableViewHeader
方法,但是我的搜索控制器消失了,當我在表格視圖中向下滾動時,標題消失了,表格視圖覆蓋了整個頁面。
有什么辦法可以在tableviewcontroller的tableview中添加某種粘性標頭,以使其停留在那里並且我的搜索控制器不會消失。
添加UIImgaeView
在HeaderView
那的TableView
。 像這樣-
let headerImageView = UIImageView.init(frame: Frame)
headerImageView.image = Image
self.tableView.tableHeaderView = headerImageView
使用UITableViewController
不能,不能像使用UIViewController
那樣添加圖像
目前,您有以下選擇
1)切換到UIViewController並添加uitableview和任何視圖。
2)如果您正在使用導航控制器,則將子視圖添加到導航控制器的視圖中
3)直接將子視圖添加到appdelegate的UIWindow
中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.