亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

添加iOS UITableView HeaderView(不是節標題)

添加iOS UITableView HeaderView(不是節標題)

iOS
慕婉清6462132 2019-11-05 16:27:15
我想添加一個表頭(而不是節頭),例如在聯系人應用程序中: 完全一樣-表格上方圖片旁邊的標簽。我希望所有視圖都是可滾動的,所以我不能將它們放在桌子外面。我怎樣才能做到這一點?
查看完整描述

3 回答

?
慕神8447489

TA貢獻1780條經驗 獲得超1個贊

您可以在Interface Builder中輕松完成此操作。只需使用表創建視圖,然后將另一個視圖放到表上。這將成為表標題視圖。將標簽和圖像添加到該視圖。有關視圖層次結構,請參見下面的圖片。 

http://img1.sycdn.imooc.com//5dc1328f00014d4e06980338.jpg


查看完整回答
反對 回復 2019-11-05
?
波斯汪

TA貢獻1811條經驗 獲得超4個贊

在Swift中:


override func viewDidLoad() {

    super.viewDidLoad()


    // We set the table view header.

    let cellTableViewHeader = tableView.dequeueReusableCellWithIdentifier(TableViewController.tableViewHeaderCustomCellIdentifier) as! UITableViewCell

    cellTableViewHeader.frame = CGRectMake(0, 0, self.tableView.bounds.width, self.heightCache[TableViewController.tableViewHeaderCustomCellIdentifier]!)

    self.tableView.tableHeaderView = cellTableViewHeader


    // We set the table view footer, just know that it will also remove extra cells from tableview.

    let cellTableViewFooter = tableView.dequeueReusableCellWithIdentifier(TableViewController.tableViewFooterCustomCellIdentifier) as! UITableViewCell

    cellTableViewFooter.frame = CGRectMake(0, 0, self.tableView.bounds.width, self.heightCache[TableViewController.tableViewFooterCustomCellIdentifier]!)

    self.tableView.tableFooterView = cellTableViewFooter

}


查看完整回答
反對 回復 2019-11-05
  • 3 回答
  • 0 關注
  • 1304 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號