How can I add a footer view to NSTableView?

邮差的信 提交于 2019-12-08 17:06:01

问题


It seems that NSTableView has no equivalent to UITableView's tableFooterView property. What is the preferred way to add a footer view to a table view in Cocoa?


回答1:


NSTableView doesn't have sections like UITableView or NSCollectionView, and therefore no headers and footers.

Instead you can do it via your datasource, if you are using a view-based table.

  1. Add a cell to your table in Interface Builder with custom styling/elements that you need in your footer. Give it an identifier like "TableFooter"
  2. Increment (by one) the number of rows returned by your NSTableViewDataSource's numberOfRowsInTableView(tableView:)
  3. and in tableView(tableView:viewForTableColumn:row:) for this last row, instantiate that item from storyboard using the identifier "TableFooter".


来源:https://stackoverflow.com/questions/13892938/how-can-i-add-a-footer-view-to-nstableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!