我制作了两张桌子ProductTable(tag = 1)&卖表(tag = 2)
ProductTable正确显示数据 但是销售表并没有显示任何细胞数量。
请告诉我为什么会这样?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView.tag==1 )
{
return ProductImages.count;
}
else
{
return MostProductImages.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.tag==1 )
{
ProductTableViewCell *cell= [_ProductTableView dequeueReusableCellWithIdentifier:@"SimpleTableView"];
if ([[ProductImages objectAtIndex:indexPath.row] isEqual: [NSNull null] ])
{
cell.product_image.image= [UIImage imageNamed:@"ic_launcher.png"];
}
else
cell.product_image.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[Productaddurl stringByAppendingPathComponent:[ProductImages objectAtIndex:indexPath.row]]]]];
cell.product_name.text= [Product_Name objectAtIndex:indexPath.row];
cell.product_mp.text= [MP objectAtIndex:indexPath.row];
cell.product_sp.text= [SP objectAtIndex:indexPath.row];
cell.product_image.transform=CGAffineTransformMakeRotation(M_PI_2);
cell.product_name.transform= CGAffineTransformMakeRotation(M_PI_2);
cell.product_mp.transform= CGAffineTransformMakeRotation(M_PI_2);
cell.product_sp.transform= CGAffineTransformMakeRotation(M_PI_2);
cell.heartButton.transform= CGAffineTransformMakeRotation(M_PI_2);
cell.rup.transform = CGAffineTransformMakeRotation(M_PI_2);
[cell.layer setBorderWidth: 0.1];
[cell.layer setCornerRadius:10.0f];
[cell.layer setMasksToBounds:YES];
[cell.layer setBorderColor:[[UIColor grayColor] CGColor]];
[self performSelectorOnMainThread:@selector(updateTable) withObject:nil waitUntilDone:NO];
return cell;
}
if (tableView.tag==2)
{
SellingTableViewCell *cell1= [_SellingTableView dequeueReusableCellWithIdentifier:@"SimpleTableCell"];
if ([[MostProductImages objectAtIndex:indexPath.row] isEqual: [NSNull null] ])
{
cell1.selling_image.image= [UIImage imageNamed:@"ic_launcher.png"];
}
else
cell1.selling_image.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[Productaddurl stringByAppendingPathComponent:[MostProductImages objectAtIndex:indexPath.row]]]]];
cell1.selling_name.text= [MostProduct_Name objectAtIndex:indexPath.row];
//NSLog(@"%@", [MostProduct_Name objectAtIndex:indexPath.row]);
cell1.selling_mp.text= [MostMP objectAtIndex:indexPath.row];
cell1.selling_sp.text= [MostSP objectAtIndex:indexPath.row];
cell1.selling_name.transform= CGAffineTransformMakeRotation(M_PI_2);
cell1.selling_mp.transform= CGAffineTransformMakeRotation(M_PI_2);
cell1.selling_sp.transform= CGAffineTransformMakeRotation(M_PI_2);
cell1.heartButton.transform= CGAffineTransformMakeRotation(M_PI_2);
cell1.selling_image.transform=CGAffineTransformMakeRotation(M_PI_2);
cell1.selling_name.numberOfLines = 2;
[cell1.layer setBorderWidth: 0.1];
[cell1.layer setCornerRadius:10.0f];
[cell1.layer setMasksToBounds:YES];
[cell1.layer setBorderColor:[[UIColor grayColor] CGColor]];
[cell1.contentView setAlpha:0];
[cell1 setUserInteractionEnabled:NO];
[self performSelectorOnMainThread:@selector(updateTable) withObject:nil waitUntilDone:NO];
return cell1;
}
return nil;
}
答案 0 :(得分:0)
MostProductImages
数组中包含一些值。viewController.swift
文件中的两个表格。您是否正确设置了两个表的委托和dataSource?您是否正确设置了两个表的标签?希望这会有所帮助:)