|
1
7
它不会要求您为任何列提供对象值,因为它没有任何列。创造一些 NSTableColumn 实例和 add them to the table view . |
|
|
2
16
我创建了默认的示例项目,然后执行了以下操作: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSRect scrollFrame = NSMakeRect( 10, 10, 300, 300 );
NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame:scrollFrame] autorelease];
[scrollView setBorderType:NSBezelBorder];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[scrollView setAutohidesScrollers:NO];
NSRect clipViewBounds = [[scrollView contentView] bounds];
NSTableView* tableView = [[[NSTableView alloc] initWithFrame:clipViewBounds] autorelease];
NSTableColumn* firstColumn = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease];
[[firstColumn headerCell] setStringValue:@"First Column"];
[tableView addTableColumn:firstColumn];
NSTableColumn* secondColumn = [[[NSTableColumn alloc] initWithIdentifier:@"secondColumn"] autorelease];
[[secondColumn headerCell] setStringValue:@"Second Column"];
[tableView addTableColumn:secondColumn];
[tableView setDataSource:self];
[scrollView setDocumentView:tableView];
[[[self window] contentView] addSubview:scrollView];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return 100;
}
- (id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSString* cellValue = [NSString stringWithFormat:@"%@ %ld", [aTableColumn identifier], (long)rowIndex];
return cellValue;
}
你可以抓取示例应用程序 TableViewInCode (哦,对于objective-c点语法,只需说no.:-) |
|
|
3
0
(从您的示例中)不会显示您正在将TableView放入ScrollView中。它是否被添加为一个子视图,而您没有显示给我们? 另外,您确定需要单独的滚动视图吗?TableView是否已经实现滚动? |
|
|
George Kim · 如何在iOS中模拟特定坐标空间中的触摸? 2 年前 |
|
|
BENG · 协调C++和Objective-C中结构的填充 2 年前 |
|
|
Community wiki · iPhone上ivar的继承问题 3 年前 |
|
|
Community wiki · 在OpenGL中显示YUV 3 年前 |
|
|
YosiFZ · pod更新依赖关系pod 3 年前 |
|
|
Community wiki · 查找iOS日历 3 年前 |