我问这个问题以前,现在更清楚,我会让你知道我的项目对象在其他细胞行显示
我添加的表视图作为子视图,并具有4段和具有1节表视图的情况下, 4(动态),3,2行。 section = 0,textfield在那里,section = 2 2 switch button,section = 3两行都有背景色。 这些所有对象我通过Xib而不是以编程方式添加, 当我向下滚动colorse进入部分0,1,并在第1,2部分中的按钮都变得混乱。
if (indexPath.section==0) {
if (indexPath.row==0) {
self.enterNameTextField.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
self.enterNameTextField.clearsOnBeginEditing =YES;
self.enterNameTextField.delegate = self;
self.enterNameTextField.tag=indexPath.row;
[email protected]"Enter youe name";
self.enterNameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[cell.contentView addSubview: self.enterNameTextField];
}
else {
[self.enterNameTextField removeFromSuperview];
}
}
if (indexPath.section==1) {
NSInteger ii=[self.sectionRows count];
if(indexPath.row== ii) {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
[email protected]"Work Out Detail";
}
else {
NSArray *kk=[self.sectionRows objectAtIndex:indexPath.row];
NSLog(@"..%@/...index=%d",[self.sectionRows objectAtIndex:indexPath.row],indexPath.row);
cell.textLabel.text=[NSString stringWithFormat:@"%@.%@",[kk objectAtIndex:2],[kk objectAtIndex:0 ]];
}
}
if (indexPath.section==2) {
if (indexPath.row==0) {
NSInteger taskData;
taskData= [[NSUserDefaults standardUserDefaults]integerForKey:@"RepetitionCheckMark"];
self.repitiiondata=[self.listOfRepititionContent objectAtIndex:taskData];
[email protected]"Repetitions";
cell.detailTextLabel.text=self.repitiiondata;
NSLog(@"cvxcv%@",self.repitiiondata);
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
if (indexPath.row==1) {
cell.accessoryView=[[UIView alloc]initWithFrame:self.coolDownSwitch.frame];
cell.accessoryView=[[UIView alloc]initWithFrame:self.warmUpSwitch.frame];
[email protected]"Warm Up(5 min.)";
int pp=[ self.wrmUpString integerValue];
if(pp==1) {
[self.warmUpSwitch setOn:YES];
}
else {
[self.warmUpSwitch setOn:NO];
}
[cell.accessoryView addSubview:self.warmUpSwitch];
}
if (indexPath.row==2) {
cell.accessoryView=[[UIView alloc]initWithFrame:self.coolDownSwitch.frame];
[cell.accessoryView addSubview:self.coolDownSwitch];
int pp=[ self.coolDwnString integerValue]
if(pp==1) {
[self.coolDownSwitch setOn:YES];
}
else {
[self.coolDownSwitch setOn:NO];
}
[email protected]"Cool Down(5 min.)";
[cell.accessoryView addSubview:self.coolDownSwitch];
}
}
}
if (indexPath.section==3) {
if (indexPath.row==0) {
[email protected]" SAVE CONTENT";
cell.textLabel.textColor=[UIColor whiteColor];
cell.backgroundColor=[UIColor redColor];
}
else {
[email protected]" DELETE CONTENT";
cell.textLabel.textColor=[UIColor whiteColor];
cell.backgroundColor=[UIColor blackColor];
}
}
}
return cell;
}
TIPS:你应该添加单元格标记 – 2013-02-27 05:21:56
你能显示整个cellforrow方法吗? – DivineDesert 2013-02-27 05:34:19
嗨@RameshRajput,而不是工作indexpath.row,分配标签到uitableview中的每个原型单元格并使用它。 – 2013-02-27 05:49:24