Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@adachi_c

NSTableView に CustomView を表示させる

More than 5 years have passed since last update.

メモ。

NSTableView にデータを表示させる方法
http://rakuishi.com/archives/5535/
上記はdataSourceから文字を返すやり方。でも、たいていの人がやりたいのはCellを返すということだと思う。
任意のViewを返すのは、iPhoneと同じくdelegateから返す。
iPhoneと違うところは、カラムがあるところ。

下記の手順で設定する。

  • カラム単位でidentifierがあるので、こいつを設定する。
    Screen Shot 2015-07-26 at 6.15.32 AM.png

  • delegate先でregisterNib:forIdentifier:する。

        NSNib *cellNib = [[NSNib alloc] initWithNibNamed:@"MECategoryTableViewCell" bundle:nil];
        [self.categoryTableView registerNib:cellNib forIdentifier:@"category_"];

        self.categoryTableView.dataSource = self;
        self.categoryTableView.delegate = self;
  • viewForTableColumn内でmakeViewWithIdentifier:する。
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    MECategoryTableViewCell *cell = [tableView makeViewWithIdentifier:@"category_" owner:self];
    [cell.textField setStringValue:[MECategory existCategories][row]];
    return cell;
}
3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?