パルスに似たアプリのサンプル スクリプトをインターネットから取得しました。これは xib ファイルで構成されており、水平方向のテーブル スクロールを利用するためにストーリーボードに入るように構成しました。
何らかの理由で、tableView.m の "cell = tableViewCell" がアサーション エラーで失敗し続けます UITableView dataSource は tableView:cellForRowAtIndexPath からセルを返す必要があります
「cell = tableViewCell」をコメントアウトすると、プログラムは問題なく実行されますが、tableViewCell に情報が渡されません。
私が見ることができない簡単な解決策はありますか?
tableView.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TableViewCell *cell = (TableViewCell*)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
CGAffineTransform rotateTable = CGAffineTransformMakeRotation(-M_PI_2);
tableViewCell.horizontalTableView.transform = rotateTable;
tableViewCell.horizontalTableView.frame = CGRectMake(0, 0, tableViewCell.horizontalTableView.frame.size.width, tableViewCell.horizontalTableView.frame.size.height);
tableViewCell.contentArray = [arrays objectAtIndex:indexPath.section];
tableViewCell.horizontalTableView.allowsSelection = YES;
cell = tableViewCell;
return cell;
}
tableViewCell.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.horizontalTableView dequeueReusableCellWithIdentifier:CellIdentifier];
for (UIImageView *view in cell.subviews) {
[view removeFromSuperview];
}
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
imageView.image = [contentArray objectAtIndex:indexPath.row]];
imageView.contentMode = UIViewContentModeCenter;
CGAffineTransform rotateImage = CGAffineTransformMakeRotation(M_PI_2);
imageView.transform = rotateImage;
[cell addSubview:imageView];
return cell;
}