0
泰伯維加載但不能從自定義單元格NSTableView的定製tablecellview不顯示任何數據
class ViewController: NSViewController,NSTableViewDataSource,NSTableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
//let color : CGColorRef = CGColorCreateGenericRGB(1.0, 0, 0, 1.0)
self.view.layer?.backgroundColor = NSColor.whiteColor().CGColor
// Do any additional setup after loading the view.
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
let cell = tableView.makeViewWithIdentifier("AppointmentCell", owner: self) as! AppointmentCell!
if tableColumn!.identifier == "Column" {
return cell
}
return cell
}
func numberOfRowsInTableView(tableView: NSTableView) -> Int {
return 5
}
func tableView(tableView: NSTableView, heightOfRow row: Int) -> CGFloat
{
return 100
}
}
class AppointmentCell: NSTableCellView {
@IBOutlet weak var Start: NSButton!
@IBOutlet weak var Increment: NSButton!
@IBOutlet weak var decrement: NSButton!
@IBOutlet weak var addNotes: NSButton!
override func drawRect(dirtyRect: NSRect) {
super.drawRect(dirtyRect)
// Drawing code here.
}
}