Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 显示在其他单元格行中的对象_Iphone_Uitableview_Object_Location_Exchange Server - Fatal编程技术网

Iphone 显示在其他单元格行中的对象

Iphone 显示在其他单元格行中的对象,iphone,uitableview,object,location,exchange-server,Iphone,Uitableview,Object,Location,Exchange Server,我以前问过这个问题,现在我会更清楚地告诉你们我的项目情况 我添加了表视图作为子视图,表视图有4个部分,部分有1,4(动态)行和3,2行。 在section=0中,文本字段在那里,section=2开关按钮,section=3两行都有背景色。 我通过Xib添加的所有对象都不是以编程方式添加的, 当我向下滚动时,颜色出现在第0,1节中,而按钮出现在第1,2节中,都变得一团糟 if (indexPath.section==0) { if (indexPath.row==0) { self

我以前问过这个问题,现在我会更清楚地告诉你们我的项目情况

我添加了表视图作为子视图,表视图有4个部分,部分有1,4(动态)行和3,2行。 在section=0中,文本字段在那里,section=2开关按钮,section=3两行都有背景色。 我通过Xib添加的所有对象都不是以编程方式添加的, 当我向下滚动时,颜色出现在第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;
     self.enterNameTextField.placeholder=@"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;
            cell.textLabel.text=@"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];
            cell.textLabel.text=@"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];
            cell.textLabel.text=@"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];
            }
            cell.textLabel.text=@"Cool Down(5 min.)";  
            [cell.accessoryView addSubview:self.coolDownSwitch];
        }
    }        
}   
if (indexPath.section==3) {        
    if (indexPath.row==0) {
        cell.textLabel.text=@"            SAVE CONTENT";
        cell.textLabel.textColor=[UIColor whiteColor];
        cell.backgroundColor=[UIColor redColor];   
    }
    else {
         cell.textLabel.text=@"            DELETE CONTENT";
         cell.textLabel.textColor=[UIColor whiteColor];    
         cell.backgroundColor=[UIColor blackColor];    
     }
  }      
 }

return cell;
}

我发现很难理解你的怀疑。 但是试试这个。 在xib中指定不同的单元标识符。 并在diff段中使用diff单元
问题是第0节正在重用第2节中的单元格。

将您的单元格标识符设置为nil。
这将对您有所帮助。

提示:您应该使用单元格标记添加您可以显示整个cellforrow方法吗?Hi@ramesrajput,而不是使用indexpath.row,将标记分配给uitableview中的每个原型单元格并使用它。谢谢我尝试了您的方法及其工作。非常感谢,请告诉我将单元格标识符设置为nil背后的概念。它总是分配新的单元格。我已经将单元格标识符设置为nil,它工作得很好,你们中的一位朋友建议我,但我仍然需要知道背后的概念。Ios不会创建所有单元格。一次只能看到那些数字。当您滚动时,将在下面重复使用退出的单元格。您将cellIdentifier指定给一个单元格。当您创建具有相同标识符的单元时,Ios会尝试重用该单元。它可以节省内存。不要使cellIdentifier为nil,而是为每个部分指定不同的值。在每个单元格中创建具有这些名称的单元格。