2016-06-11 76 views
0

我有一個tableView音樂專輯。對於tableView的每個cell我想要顯示音樂專輯封面藝術以及相應專輯的音樂曲目列表。UITableView裏面的UITableViewCell

所以基本上,在每個音樂專輯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來填充它。

我知道這是一個令人困惑的事情,在風格上它在大多數情況下是沒有意義的,但是有沒有人知道如何做到這一點?

回答

1

您應該使用章節。每個部分的標題應該顯示專輯封面,部分的每個單元格應顯示歌曲名稱。不要在numberOfSections方法補充細胞內視表格視圖...

返回件數,裏面的viewForHeaderInSection添加專輯封面,並在cellForRow...檢查哪一部分是和顯示歌曲名稱....

+0

酷我會試試這個! – SRMR