• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question on NSScrollView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on NSScrollView


  • Subject: Re: Question on NSScrollView
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 01 May 2014 22:12:00 -0700

On May 1, 2014, at 17:25 , Varun Chandramohan <email@hidden> wrote:

> Yes I have implemented tableView:isGroupRow.
> - (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
>     DesktopEntity *entity = _tableContents[row];
>     if ([entity isKindOfClass:[DesktopFolderEntity class]]) {
>         return YES;
>     }
>     return NO;
> }
>
> What is wrong with this?

Nothing at all! Rows corresponding to a ‘DesktopFolderEntity’ are group rows, and all the others are not.

> Also I implemented
> - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
>     DesktopEntity *entity = _tableContents[row];
>     if ([entity isKindOfClass:[DesktopFolderEntity class]]) {
>         NSTableCellView *groupCell = [tableView makeViewWithIdentifier:@"GroupCell" owner:self];
>         [groupCell.textField setStringValue:entity.name];
>         return groupCell;
>     }
>     return nil;
> }
>
> Are you saying I should not return nil here?

Well, you are returning nil for rows that aren’t ‘DesktopFolderEntity’, which doesn’t seem a good idea, but that isn’t the issue you asked about.

In this code, you should return a view with identifier “GroupCell” — as you have done — for rows that are ‘DesktopFolderEntity’. Since these are indeed group rows, this correctly gives them the group-row appearance (the one with the gray background).

That is, your table view is showing exactly what you asked it to show.

Your ‘tableView:viewForTableColumn:’ method is, however, missing some code. You need to return a view for non-group rows (that would probably be a view with identifier ‘DataCell’, if you have the default setup in IB), and you need to test tableColumn (and possibly tableColumn.identifier). (‘tableColumn == nil’ means that you’re being asked for a group-row view. Otherwise you’re being asked for a per-column view.)
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Question on NSScrollView
      • From: Varun Chandramohan <email@hidden>
References: 
 >Re: Question on NSScrollView (From: Varun Chandramohan <email@hidden>)
 >Re: Question on NSScrollView (From: Quincey Morris <email@hidden>)
 >Re: Question on NSScrollView (From: Varun Chandramohan <email@hidden>)

  • Prev by Date: Re: Question on NSScrollView
  • Next by Date: Re: Question on NSScrollView
  • Previous by thread: Re: Question on NSScrollView
  • Next by thread: Re: Question on NSScrollView
  • Index(es):
    • Date
    • Thread