1

I am using NSTableView to display my data. I have to change table data by clicking some buttons. So number of rows are not fix. Sometime it use only 2 rows and sometimes 12.
When it takes only 2 rows then table looks not good.

What i want is my tableview height can be resize according to number of rows or cell used.
I tried this but its not working with me.. Infect i can't even see my table by using that code. I am using NSWindowController.

EDIT :

- (void)addImageToTableView
{

[tableView setBackgroundColor:[NSColor clearColor]];
[tableView setHeaderView:nil];

if([title isEqualToString:@"First"]){

    if ([[arrayController arrangedObjects] count] != 0) 
    { 
        [arrayController removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[arrayController arrangedObjects ] count])]]; 
    }

    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"MS.png"],@"image", nil]];
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"CVS.png"],@"image", nil]];
}

if ([title isEqualToString:@"Second"]) {

    if ([[arrayController arrangedObjects] count] != 0) 
    { 
        [arrayController removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[arrayController arrangedObjects ] count])]]; 
    }

    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"NS.png"],@"image", nil]];
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"EM.png"],@"image", nil]] ;
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"RES.png"],@"image", nil]];
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"ERS.png"],@"image", nil]] ;
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"RS.png"],@"image", nil]];
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"FB.png"],@"image", nil]] ;
    [arrayController addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSImage imageNamed:@"SKIN.png"],@"image", nil]];

}
    [tableView reloadData];
    [self windowDidLoad];
}
-(void)windowDidLoad{
    [super windowDidLoad];

}

Any other suggestion??
Thanks in advance..!!

Community
  • 1
  • 1
iUser
  • 1,075
  • 3
  • 20
  • 49
  • All answers here will be the same that are in link that u've posted. Show us your current not working code. – Nekto Sep 27 '11 at 10:27
  • Let me edit.. But u can see my code here http://stackoverflow.com/questions/7553370/window-is-not-releasing-when-switching-to-another-window – iUser Sep 27 '11 at 10:29
  • What about if you in `- (void)windowDidLoad` will try to set frame of `tableView`? `[tableView setFrame:CGRectMake(0, 0, 10, 20)];` – Nekto Sep 27 '11 at 10:32

0 Answers0