typ*_*ror 12 iphone uitableview
我正在尝试自定义UITableView.到目前为止,它看起来不错.但是当我使用自定义UITableViewCell子类时,当只有3个单元格时,我没有得到空白表格单元格:
alt text http://img193.imageshack.us/img193/2450/picture1zh.png
使用默认的TableView样式,我可以获得重复的空白行来填充视图(例如,邮件应用程序具有此功能).我试图在UITableView上将backgroundColor模式设置为相同的tile背景:
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"score-cell-bg.png"]];
moneyTableView.backgroundColor = color;
Run Code Online (Sandbox Code Playgroud)
...但是瓷砖在TableView的顶部之前开始了一点,所以一旦实际的单元格完成显示,瓷砖就会关闭:
替代文字http://img707.imageshack.us/img707/8445/picture2jyo.png
我如何自定义我的tableview,但如果行数少于填充页面,仍保留空白行?
您偶然删除了背景颜色和分隔符样式吗?如果你这样做,那可能就是为什么没有额外的细胞.我认为默认的UITableView不会真正添加更多单元格,它只是具有创建幻觉的分隔符样式,并且因为它具有白色背景,所以它们看起来像单元格.
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
Run Code Online (Sandbox Code Playgroud)
如果不是这种情况,您可以尝试添加无法选择的额外单元格:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return ([source count] <= 7) ? 7 : [source count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set all labels to be blank
if([source count] <= 7 && indexPath.row > [source count]) {
cell.textLabel.text = @"";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else {
cell.textLabel.text = [source objectAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11145 次 |
| 最近记录: |