UITableView - 如何仅显示包含数据的行

nit*_*ram 10 iphone objective-c uitableview ipad ios

如何显示UITableView仅包含数据而不包含其他行的行.默认情况下UITableView显示10行.如果我们有三行数据它只显示三行我该如何实现?谢谢.

Dim*_*ris 32

如果需要,您可以设置页脚视图并使其不可见.分隔符仅出现在包含数据的行中:

self.theTableView.tableFooterView = [[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 10.0f)] autorelease];
Run Code Online (Sandbox Code Playgroud)


ios*_*ner 17

试试这个 ..

self.tableView.tableFooterView = [UIView new];
Run Code Online (Sandbox Code Playgroud)


HG'*_*G's -2

您可以在以下函数的返回参数中指定所需的行数:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return NUMBER_OF_ROWS;
}
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅 UITableView 的 Apple 文档。

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html