1
我創建一個視圖基於表格視圖一個非常簡單的演示項目及以下NSTableViewDelegate
實施高度靈活的可編輯的NSTextField
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSTableCellView *result = [tableView makeViewWithIdentifier:@"MyView" owner:self];
result.textField.stringValue = [NSString stringWithFormat:@"Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld Row %ld end", row, row, row, row, row, row, row, row, row, row, row, row];
return result;
}
通過在小區設置NSTextField
爲自動換行,自動將文本字段得到正確的高度:
當我從None
到改變NSTextField
的行爲3210,文本字段只顯示一行:
我不知道爲什麼 - 任何想法?謝謝!