我自定義NSTableView就像我在UITableView中做的一樣。我實現了數據源和委託。在代碼中,我喜歡這樣的:自定義NSTableViewCell
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
ZJCellView *cellView = [tableView makeViewWithIdentifier:cellIdentifier owner:self];
//this is a custom view
if (cellView == nil)
{
CGRect rect = CGRectMake(0, 0, tableView.frame.size.width, kTableViewCellHeight);
cellView = [[[ZJCellView alloc] initWithFrame:NSRectFromCGRect(rect)] autorelease];
cellView.identifier = cellIdentifier;
// some other controls
}
return cellView;
我這樣做的習慣就像我在iOS中做的一樣。 問題是存在於左,右一個邊界,如:
我試圖改變細胞視圖的框架,它似乎是沒有用的。 因爲這是在iOS中定製單元格的正確方式,所以我想知道Cocoa中它錯誤的位置。
任何身體能幫助我嗎? 謝謝。
我已經用tableview的寬度初始化單元格視圖。問題存在。 – scorpiozj 2012-07-22 11:50:30