ios - UITableViewCell 内部的 UITableView

标签 ios objective-c uitableview

我有一个 tableView音乐专辑。对于每个celltableView我想显示音乐专辑封面以及相应专辑的音乐轨道列表。

基本上,在每张音乐专辑中 UITableViewCell上半部分将有音乐专辑封面艺术,以及 UITableView在下半部分。

UITableViewCell示例:

enter image description here

我最多在上半部分添加音乐专辑封面艺术,以及空白UITableView在下半部分。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    AlbumsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    MPMediaItem *rowItem = [[albumsArrayForTVC objectAtIndex:indexPath.row] representativeItem];
    MPMediaItemArtwork *artwork = [rowItem valueForProperty:MPMediaItemPropertyArtwork];
    inputImage = [artwork imageWithSize: CGSizeMake (1024, 1024)];
    if (inputImage) {
        cell.backgroundImageView.image = inputImage;
    } else {
        cell.backgroundImageView.image = nil;
    }

    UITableViewCell *songCell = [cell.songTableView dequeueReusableCellWithIdentifier:@"OtherCell"];
    songCell.textLabel.text = @"This text doesn't show up yet";
    return cell;
}

我想不通里面cellForIndexPath如何填写UITableView歌曲。我只是想使用静态 textLabel.text现在,尽管我最终会通过实际的 NSArray 来填写它歌曲。

我知道这是一件令人困惑的事情,而且在大多数情况下从风格上讲它没有意义,但是有人知道如何做到这一点吗?

最佳答案

您应该使用部分。每个部分标题应显示专辑封面,部分中的每个单元格应显示歌曲名称。不要在单元格 View 中添加表格 View ...

numberOfSections方法中返回专辑数量,在viewForHeaderInSection中添加专辑封面,并在cellForRow...中检查哪个部分是并显示歌曲名称....

关于ios - UITableViewCell 内部的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37768934/

相关文章:

iphone - iphone 和 ipad 之间 modalviewcontroller 的不同方向行为

objective-c - 在Objective-C中播放字符串数组中的声音

iphone - 从关卡深处的字典中删除一个项目

ios - 使用自定义单元格/自定义背景图像对 UITableView 进行分组

ios - 当我滚动 UITableview 时自动滚动 UICollectionView

ios - 发电机 : Decrement/Subtract a key/value

ios - 在用户设置中播放默认通知声音

iOS OpenGLES 内存泄漏

ios - 如何检查一个实体是否与另一个实体相关

ios - Swift XCode - Storyboard 中的更改未反射(reflect)在 iPhone 模拟器中