我正在使用 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);
}
当我的展开视图宽度大于我的视图宽度时,我会遇到这个问题。
然后我的问题是加载视图时,我的按钮被添加到第一列和第四列(案例 0 和案例 4),但我只将它添加到第一列。请帮助我过去几天我一直在挣扎。谢谢你。