I am trying to imitate the album page of iTunes using uitableviewcontroller
, but then I think I might have been going in a wrong direction.
My plan is to do something in tableView: cellForRowAtIndexPath:
. When indexPath.row == 0
, I do the description of album (i.e. the upper part), else I do the description of songs (i.e. the lower part).
Here is my code:
- (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;
}
There are two places That I don't have simple idea to implement it:
Firstly, in the album page of iTunes, there is a segmented control (see the image). When I press other segment, say "review", the upper part remains there while the whole lower parts has been changed.
Secondly, I don't know how to close the gap show in the image (circle in red).
So, I think may be there are some other smarter(or easier) way to do it. Like, is it possible to divide the page into two part: then the do the upper part by a view; and do the lower part by a table view? (just my guess)
Please advice. Thank you.