开发者

View-based NSOutlineView row badges

I'm still struggling with the View-Based NSOutlineViews introduced with OSX Lion. While ev开发者_开发百科erything works quite good now, I'd like to add Mail.app-like unread badges to rows.

Is there a better way for View-Based NSOutlineViews than following the example of -(void)drawBadgeForRow:(NSInteger)rowIndex inRect:(NSRect)badgeFrame in PXSourcelist ?

Thanks, Bucks


In case anybody encounters the same problem, I've found a solution in the Lion release notes that is actually quite simple.

First subclass NSTableCellView, add an IBOutlet for an NSButton and a @synthesize/@property statement to it. Then open the NSTableCellView that should have a badge in Interface Builder. Set it's class to your newly created subclass and add a button to it. Set the button style to "inline" and it's type to "switch".

Now select the NSTableCellView again and connect the NSButton IBOutlet to your added button. That's it. You can now call e.g. [[cellView button] setTitle@"123"]] to set the rows badge label to 123 or any arbitrary string.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜