开发者

HTML-like view in Cocoa?

learning Cocoa can be pretty tough for web developers. Some things are so simple in HTML, and I have no idea, how to do this in Cocoa.

Let me just show you an image here, to show you what I have on my mind.

HTML-like view in Cocoa?

So it's kinda like a blog. Each post has variable length, so it can take up some space. Also, you're able to scroll through posts.

I was thinking about using NSTableView or NS开发者_如何学JAVACollectionView, but since I don't know much about Cocoa, I'm asking you for advice.

Also please do link any related articles.

Updates

So here are some things that I discovered.

  1. I could make a subclass of NSCell and use it in Table View. I can use it, I can put there a string, something like this:

http://pastie.org/1140412

(please take a look at this code, I'm wondering if I should use awakeFromNib/setDataCell combination)

  1. But string is not enough. I need a NSTextView. The problem is, it doesn't have method like drawInRect: withAttributes:. So I don't know how to draw it into that cell. I guess I'm missing some basics here, so I'm just gonna study some Cocoa views now.

Any ideas are welcome.


You want to use a NSTableView. And I will recommend to take a look/glance at NSTableView, NSTableViewDelegate and NSTableViewDataSource docs: http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html

http://developer.apple.com/mac/library/documentation/cocoa/reference/NSTableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008622

http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40004178

You choose the object you want to be your datasource depending on the data you have. The delegate is the object that helps you to so some settings, like rows, groups, cells, etc. There are useful methods of NSTableViewDelegate you want to implement like – tableView:heightOfRow:

and just google NSTableView tutorial or something, there are many good examples ;)


You could just use a WebView and write it in HTML.

Look at http://mattgemmell.com/source for an example: the Skinnable App one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜