iOS 数据未发送到自定义 TableViewCell
iOS Data didn't sent to custom TableViewCell
我正在处理一个使用自定义 TableCell 的项目。这是我的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"customScoreCell";
ScoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
cell = [[ScoreTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.classNameLabel.text = courseNameArray[indexPath.row];
cell.creditLabel.text = courseCreditArray[indexPath.row];
cell.scoreLabel.text = courseScoreArray[indexPath.row];
NSLog(@"%@",courseScoreArray[indexPath.row]);
return cell; }
NSLOG 有输出,但我无法在自定义单元格的这三个标签中显示该数据。我可以在 运行 之后看到这些单元格,但它只显示与我在创建自定义单元格时将它们放入属性检查器中的信息相同的信息。有人找到解决方案了吗?
UPDATE 我尝试将 cell.creditLabel.text = courseCreditArray[indexPath.row];
更改为 cell.textLabel.text = courseCreditArray[indexPath.row];
并显示了这一点。
并且这是我想在显示 "credit" 的地方显示的数据。
这就是我设置 IBOutlet 的方式:
我认为您应该检查单元格标识符以及您对以下功能的实现
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView//No compulsion if you have only 1 section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section //Compulsory to specify the number of rows.
干杯!
我的代码是正确的,清理后,删除模拟器中的应用程序,然后再次运行程序,它工作...我不知道为什么在我之前做了两次相同的事情发送这个 post 没用...太混乱了
我正在处理一个使用自定义 TableCell 的项目。这是我的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"customScoreCell";
ScoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
cell = [[ScoreTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.classNameLabel.text = courseNameArray[indexPath.row];
cell.creditLabel.text = courseCreditArray[indexPath.row];
cell.scoreLabel.text = courseScoreArray[indexPath.row];
NSLog(@"%@",courseScoreArray[indexPath.row]);
return cell; }
UPDATE 我尝试将 cell.creditLabel.text = courseCreditArray[indexPath.row];
更改为 cell.textLabel.text = courseCreditArray[indexPath.row];
并显示了这一点。
并且这是我想在显示 "credit" 的地方显示的数据。
这就是我设置 IBOutlet 的方式:
我认为您应该检查单元格标识符以及您对以下功能的实现
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView//No compulsion if you have only 1 section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section //Compulsory to specify the number of rows.
干杯!
我的代码是正确的,清理后,删除模拟器中的应用程序,然后再次运行程序,它工作...我不知道为什么在我之前做了两次相同的事情发送这个 post 没用...太混乱了