我正在使用 Swift 2.3 和 Xcode 8 Beta 1 将我的应用程序更新到 iOS10,我发现UITableViewHeaderFooterContentView
在我的UITableViewHeaderFooterView
.
在 Xcode 8 Beta 1 模拟器上,UIButton 适用于 iOS9.3,但不适用于 iOS10。
1) 有这方面的文件吗?
2) 如何确保我的 UI 元素位于 iOS10 中新的 Content View 之上?(或允许通过 触摸UITableHeaderFooterContentView
)
谢谢!
表头
import UIKit
class TableHeader: UITableViewHeaderFooterView {
@IBOutlet weak var dayLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var addNewEventButton: UIButton!
}
Code In View Controller
dateCell.addNewEventButton
是 iOS10 中不再接收触摸的 UIButton
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let tintColor = TintManager().getTintColour()
let dateCell:TableHeader = tableView.dequeueReusableHeaderFooterViewWithIdentifier("TableHeader") as! TableHeader
//dateCell.bringSubviewToFront(dateCell.addNewEventButton)
dateCell.dayLabel.text = Dates.day.uppercaseString
dateCell.dateLabel.text = Dates.date
dateCell.backgroundView = UIView(frame: dateCell.frame)
dateCell.backgroundView!.backgroundColor = tintColor
dateCell.dayLabel.textColor = UIColor.whiteColor()
dateCell.dateLabel.textColor = UIColor.whiteColor()
dateCell.addNewEventButton.backgroundColor = tintColor
dateCell.addNewEventButton.tag = section
dateCell.addNewEventButton.layer.cornerRadius = 20.0
if (savedEventView.superview === self.view) {
dateCell.addNewEventButton.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
dateCell.addNewEventButton.addTarget(self, action: #selector(ViewController.userPressedAddButtonToInsertSavedEvent(_:)), forControlEvents:.TouchUpInside)
} else {
dateCell.addNewEventButton.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
dateCell.addNewEventButton.addTarget(self, action: #selector(ViewController.userPressedAddNewEventOnTableViewHeader(_:)), forControlEvents:.TouchUpInside)
}
return dateCell
}