我正在使用mdspreadview单元格:https://github.com/mochidev/MDSpreadView 来自上面的链接。
当我横向滚动时,cellforrowatindexpath
方法被调用,我的单元格值会发生变化。
- (MDSpreadViewCell *)spreadView:(MDSpreadView *)aSpreadView cellForRowAtIndexPath:(MDIndexPath *)rowPath forColumnAtIndexPath:(MDIndexPath *)columnPath
{
static NSString *cellIdentifier = @"Cell";
MDSpreadViewCell *cell = [aSpreadView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[MDSpreadViewCell alloc] initWithStyle:MDSpreadViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
switch (columnPath.row) {
case 0:
{
radiobutton=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 10, 20)];
[radiobutton setImage:[UIImage imageNamed:@"radio_button_off.png"] forState:UIControlStateNormal];
[radiobutton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
radiobutton.titleLabel.font =[UIFont systemFontOfSize:14.f];
cell.backgroundColor=[UIColor blackColor];
[cell addSubview:radiobutton];
break;
}
case 1:
cell.textLabel.text=[self.timearray objectAtIndex:rowPath.column];
break;
case 2:
cell.textLabel.text=[self.firstnamearray objectAtIndex:rowPath.column];
break;
case 3:
cell.textLabel.text=[self.lastnamearray objectAtIndex:rowPath.column];
break;
case 4:
cell.textLabel.text=[self.agearray objectAtIndex:rowPath.column];
break;
case 5:
cell.textLabel.text=[self.reasonarray objectAtIndex:rowPath.column];
break;
case 6:
cell.textLabel.text=[self.statusarray objectAtIndex:rowPath.column];
default:
break;
}
NSLog(@"%d,%d,%d,%d,%d,%d",rowPath.section,columnPath.section,rowPath.row,columnPath.row,rowPath.column,columnPath.column);
return cell;
}
- (void)spreadView:(MDSpreadView *)aSpreadView didSelectCellForRowAtIndexPath:(MDIndexPath *)rowPath forColumnAtIndexPath:(MDIndexPath *)columnPath
{
[spreadView deselectCellForRowAtIndexPath:rowPath forColumnAtIndexPath:columnPath animated:YES];
NSLog(@"Selected %@ x %@", rowPath, columnPath);
}
当我的展开视图宽度大于我的视图宽度时,我遇到了这个问题。
然后我的问题是当加载视图时我的按钮被添加到第一列和第4列(案例0和案例4),但我只将它添加到第一列。请帮助我,过去几天我一直在努力。谢谢。