【发布时间】:2013-11-25 06:06:04
【问题描述】:
我正在尝试使用 uitableviewcontroller 来模仿 iTunes 的专辑页面,但后来我想我可能走错了方向。
我的计划是在 tableView: cellForRowAtIndexPath: 做点什么。 indexPath.row == 0时,我做专辑描述(即上半部分),否则我做歌曲描述(即下半部分)。
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (indexPath.row == 0 ){
CGRect imageFrame = CGRectMake(5, 5, 69, 69);
UIImageView *coverFram = [[UIImageView alloc] initWithFrame:imageFrame];
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"cover" ofType:@"jpg"];
coverFram.image = [[UIImage alloc] initWithContentsOfFile:imagePath];
[cell.contentView addSubview:coverFram];
}else{
NSInteger adjustedIndexPathRow = indexPath.row - 1;
cell.textLabel.text = [self.cellRow objectAtIndex:adjustedIndexPathRow];
}
return cell;
}
有两个地方我没有简单的想法来实现它:
首先,在iTunes的专辑页面中,有一个分段控件(见图)。当我按下其他部分时,说“review”,上半部分仍然存在,而整个下半部分已更改。
其次,我不知道如何关闭图像中的间隙显示(红色圆圈)。
所以,我认为可能还有其他更聪明(或更简单)的方法可以做到这一点。就像,是否可以将页面分为两部分:然后通过视图执行上部;并通过表格视图做下部? (只是我的猜测)
请指教。谢谢。
【问题讨论】:
-
在我看来,带有图像的最顶层视图是表头视图(其中有一个水平滚动的滚动视图或者可能是一个集合视图)。分段控件似乎位于部分标题中,因为当您滚动时它会粘在屏幕顶部。当您单击其中一个按钮时,您只需更改表格视图显示的内容。
标签: ios iphone objective-c xcode uitableview