我需要这样做:
。
是UITableView
吗?或者我该怎么做呢?任何想法都是受欢迎的。
代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
if (indexPath.row == 0) return cell1;
} else if (indexPath.section == 1) {
if (indexPath.row == 0) return cell2;
} else if (indexPath.section == 2) {
if (indexPath.row == 0) return cell3;
}
}
发布于 2011-09-22 14:50:57
它最有可能是一个UITableView。可能不是(它可以是添加了视图的UIScrollView,就像在表视图中添加部分一样)。
但是,如果您想创建类似于图像中的内容,我建议您使用带有自定义单元格的UITableView。因为在这种情况下,实现表视图更简单,因为您只需关注表视图的委托和dateSource,而不必担心按顺序对齐视图。
使用带有半透明、灰色边框、黑色背景视图的分段表格视图作为单元格的backgroundView。添加标签和箭头作为单元格的子视图。您可以添加箭头作为accessoryView,但这将成为垂直居中,但在图像中,箭头显示在单元格的略上方。
每个部分中应该只有一个单元格。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
可以有任意数量的部分(此处为3个)。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3; // Can be any number
}
发布于 2011-09-22 14:48:46
是的,这很可能是一个样式化的表视图。See this guide或this nice tutorial。
发布于 2011-09-22 15:04:04
您可以在中使用tableView来完成此操作
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//here place return your array contents
}
https://stackoverflow.com/questions/7510653
复制相似问题