xcode 类似 UITableView 的 NSTableView
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5369186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UITableView-like NSTableView
提问by burki
I wondered how I can make a NSTableView
to behave like a UITableView
on iOS. For example, splitting the content into sections as well as the typical behaviour of the section headers.
我想知道如何让NSTableView
aUITableView
在iOS上表现得像 a 。例如,将内容拆分为部分以及部分标题的典型行为。
Is that possible? If so, how?
那可能吗?如果是这样,如何?
Thank you very much.
非常感谢。
采纳答案by Anne
Check NoodleStickyRowTableView:
http://www.noodlesoft.com/blog/2009/09/25/sticky-section-headers-in-nstableview/
检查 NoodleStickyRowTableView:http://www.noodlesoft.com/blog/2009/09/25/sticky-section-headers-in-nstableview/
It's part of NoodleKit:
https://github.com/MrNoodle/NoodleKit
它是 NoodleKit 的一部分:https:
//github.com/MrNoodle/NoodleKit
回答by chris
One of the differences is that UITableView's "cells" are actually Views, while NSTableView's are proper cells. Views suck up more memory and there's a bit of work involved in getting NSTableView to accept views like cells, then a bit more to optimize it so that if you have a huge list it isn't too memory intesnive.
区别之一是 UITableView 的“单元格”实际上是视图,而 NSTableView 是正确的单元格。视图会占用更多内存,让 NSTableView 接受像单元格这样的视图需要做一些工作,然后再优化它,这样如果你有一个巨大的列表,它就不会太占用内存。
Luckily it's already (mostly) been done, and there's a github project:
幸运的是,它已经(大部分)完成了,并且有一个 github 项目:
1) https://github.com/Perspx/PXListView#readme(also check his blog for more info) 2) http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/
1)https://github.com/Perspx/PXListView#readme(也可以查看他的博客了解更多信息)2)http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-合适的视图/
Good luck
祝你好运
回答by johndpope
I wasted several days on this - so you don't have to.
我在这上面浪费了几天 - 所以你不必这样做。
There is a Twitter UI framework TwUI which they went to a lot of trouble to get their desktop clients to look and behave like the iPhone. The Appkit is showing its age these days.
有一个 Twitter UI 框架 TwUI,他们为了让他们的桌面客户端看起来和行为像 iPhone 一样费了很大的劲。Appkit 这些天显示它的年龄。
The con with this library is you can't add NSViews to their TWUIViews.
This maybe fine if you haven't spent a lot of time creating custom nsviews.
You can try this fork which I hacked to mimic the sticky header view.
It has group based tableviews like uitableview.
https://github.com/johndpope/osx-stickyheaders
这个库的缺点是你不能将 NSViews 添加到他们的 TWUIViews。如果您没有花费大量时间创建自定义 nsview,这可能没问题。你可以试试这个 fork,我用它来模仿粘性标题视图。它有像uitableview这样的基于组的tableviews。
https://github.com/johndpope/osx-stickyheaders
It turns out Apple have a nice sample library here https://developer.apple.com/library/mac/samplecode/TableViewPlayground/Introduction/Intro.html
事实证明,Apple 在这里有一个不错的示例库 https://developer.apple.com/library/mac/samplecode/TableViewPlayground/Introduction/Intro.html
And a simplified version here which demonstrates the FloatsGroupRows property with this line
和这里的简化版本,它演示了此行的 FloatsGroupRows 属性
[self.tableView setFloatsGroupRows:YES]
which for all intents and purposes makes the nstableview / sections look like a uitableview. https://github.com/TomLiu/PlayTableView
出于所有意图和目的,这使 nstableview / 部分看起来像一个 uitableview。 https://github.com/TomLiu/PlayTableView
The con with that is - it's not available for cell based table views.
缺点是 - 它不适用于基于单元格的表格视图。
It is only available on View Based tableviews.
它仅适用于基于视图的表视图。
Since Microsoft have recently reversed engineered UIKit including the UITableView - in c++, it may one day someone be so kind to port this back to OSX. An exercise for the reader. https://github.com/Microsoft/WinObjC/blob/master/Frameworks/UIKit/UITableView.mm
由于微软最近在 C++ 中逆向设计了包括 UITableView 在内的 UIKit,所以有一天可能会有人将它移植回 OSX。供读者练习。 https://github.com/Microsoft/WinObjC/blob/master/Frameworks/UIKit/UITableView.mm