2
我有UITableView
其中我添加了一個UIButton
。問題是它只顯示在標題的頂部。如何在所有章節標題中添加按鈕,以便我可以使該部分交互?UITableView的交互式部分標題
下面是用於添加的UITableView
func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
header.contentView.backgroundColor = UIColor(red: 255/255, green: 200/255, blue: 20/255, alpha: 1.0) // Just some random color
header.textLabel!.textColor = UIColor.whiteColor()
let btn = UIButton(type: UIButtonType.Custom) as UIButton
btn.frame = CGRectMake(header.frame.width - 62, 0, 50, 50)
btn.addTarget(self, action: "pressed:", forControlEvents: .TouchUpInside)
btn.setTitle("Direction", forState: .Normal)
btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
header.contentView.addSubview(btn)
}
節頭按鈕誰能告訴我如何添加在每節的互動按鈕的代碼?
是否有任何擴大部分的可能性。當我嘗試添加這個時,我無法看到章節標題。 –