【发布时间】:2014-02-08 05:00:12
【问题描述】:
我尝试在表格视图中显示数组的对象。 这是一个单屏应用程序,我正在使用情节提要。 运行时 - 表格视图显示为空网格。不显示对象的数据。什么可能导致这个? 有 2 个必需的方法 numberOfRowsInSection 和 cellForRowAtIndexPath 我怀疑是最后一个。 .h 文件包含这一行:
@interface MYViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
我按照您的建议通过代码设置了委托和数据源。仍然是空的网格。
这是我的实现: -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [listRecipes.recipeArray count]; }
-(UITableViewCell )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString cellIdentifier = @"ListCellIdentifier"; MYCustomListCell* listCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; NSString* dataString = listRecipes.recipeArray[indexPath.row]; listCell.listName.text = dataString; listCell.imageView.image = [UIImage imageNamed:dataString]; return listCell; }
我尝试在 MVC 中显示数组中的数据。 如果数组是本地的 - 显示数据
你能告诉我该怎么做吗? 提前谢谢你。
【问题讨论】:
标签: ios objective-c uitableview storyboard xcode5