Reputation: 3370
Here are my 2 NSTableCellViews:
The 1st is bigger than the 2nd (this one is used when the user is searching the tableview and there are no results) but when i run my app the 2nd gets the size of the 1st:
Why is this happening? Here's my part of the code
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
if (noResults){
return 1;
}else{
return [array count];
}
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
if (noResults){
NSTableCellView *result = [tableView makeViewWithIdentifier:@"NoResults" owner:self];
result.textField.stringValue = [NSString stringWithFormat:@"No results for \"%@\"", _searchTXT.stringValue];
return result;
}else{
SearchTableCell *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
result.textField.stringValue = @"Name";
result.textField2.stringValue = @"Last Name";
return result;
}
}
Upvotes: 1
Views: 643
Reputation: 2792
For a view based NSOutlineView, implement the delegate method outlineView:heightOfRowByItem:
to return the desired row height.
To avoid constants within your code, consider determining the height from the associated view:
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
NSView* view = [self outlineView:outlineView viewForTableColumn:nil item:item];
return (view ? NSHeight(view.frame) : outlineView.rowHeight);
}
Upvotes: 1
Reputation: 81
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (noResults){
// return NSTableCellView height here;
}else{
// return SearchTableCell height here;
}
}
Hope this helps you.
Upvotes: 1
Reputation: 6037
You need to implement the tableView:heightForRowAtIndexPath: method. Otherwise the cell will all be the height of the table views rowHeight property.
Upvotes: 2