Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 情节提要表视图控制器未显示用户定义的音乐列表_Iphone_Xcode_Uitableview_Storyboard - Fatal编程技术网

Iphone 情节提要表视图控制器未显示用户定义的音乐列表

Iphone 情节提要表视图控制器未显示用户定义的音乐列表,iphone,xcode,uitableview,storyboard,Iphone,Xcode,Uitableview,Storyboard,我可能遗漏了一些非常明显的东西,但是: 我正在尝试将一个项目迁移到故事板中,但是我很难让我的表视图控制器显示用户定义的数据 基本上,该项目使用一个媒体选择器来创建一个歌曲队列,应用程序可以完美地播放这些歌曲。当我试图在表视图中显示这个用户定义的列表时,我的问题就开始了,它根本不显示任何信息!(我的旧.xib文件工作正常!) 表视图控制器的my.h: #import <UIKit/UIKit.h> #import <MediaPlayer/MediaPlayer.h> #i

我可能遗漏了一些非常明显的东西,但是: 我正在尝试将一个项目迁移到故事板中,但是我很难让我的表视图控制器显示用户定义的数据

基本上,该项目使用一个媒体选择器来创建一个歌曲队列,应用程序可以完美地播放这些歌曲。当我试图在表视图中显示这个用户定义的列表时,我的问题就开始了,它根本不显示任何信息!(我的旧.xib文件工作正常!)

表视图控制器的my.h:

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "MusicViewController.h"

@protocol MusicTableViewControllerDelegate; // forward declaration

@interface MusicTableViewController : UITableViewController     <MPMediaPickerControllerDelegate, UITableViewDelegate> {

__unsafe_unretained id <MusicTableViewControllerDelegate>   delegate;

}


@property (nonatomic, assign) id <MusicTableViewControllerDelegate> delegate;
@property (nonatomic, strong) NSMutableArray *mediaItemCollectionTable;

@end

@protocol MusicTableViewControllerDelegate

// implemented in MainViewController.m
- (void) musicTableViewControllerDidFinish: (MusicTableViewController *) controller;
- (void) updatePlayerQueueWithMediaCollection: (MPMediaItemCollection *) mediaItemCollection;

@end

我完全不明白为什么它不归还任何东西

在情节提要中,检查表的内容是否设置为静态单元格。如果设置为静态单元格,请将其更改为动态原型


另外,在您的代码中,在cellforrowatinexpath中,您在哪里声明了onobject“cell”。我看到直接比较
如果(cell==nil)
它没有在任何地方声明。

我最终解决了这个问题结果显示,我需要使用Prepare for Segue将数据推送到表中,这是将应用程序传输到基于情节提要的应用程序的结果。

我将放置
NSLog(@“Controller:%@,Queue:%@,Items:%@,Count:%d”,mainViewController,currentQueue,currentQueue.Items,[currentQueue.Items Count])就在返回[currentQueue.items count]之前#import "MusicTableViewController.h"
#import "MusicViewController.h"

@interface MusicTableViewController ()

@end

@implementation MusicTableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {

}
return self;
}

@synthesize delegate;           // The main view controller is the delegate for this class.
@synthesize mediaItemCollectionTable;   // The table shown in this class's view.


// Configures the table view>
- (void)viewDidLoad
{
[super viewDidLoad];

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

 // Return the number of sections.
 return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.

MusicViewController *mainViewController = (MusicViewController *) self.delegate;
MPMediaItemCollection *currentQueue = mainViewController.userMediaItemCollection;

return [currentQueue.items count];


}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


if (cell == nil) {

    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
                                 reuseIdentifier: @"Cell"];

}

MusicViewController *mainViewController = (MusicViewController *) self.delegate;
MPMediaItemCollection *currentQueue = mainViewController.userMediaItemCollection;
MPMediaItem *anItem = (MPMediaItem *)[currentQueue.items objectAtIndex:indexPath.row];

    cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle];

return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

[tableView deselectRowAtIndexPath: indexPath animated: YES];

@end