开发者

NSTableView Height resizing

开发者 https://www.devze.com 2023-04-08 11:45 出处:网络
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.

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 (开发者_Python百科[[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..!!

0

精彩评论

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