Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen we scroll custom table then cell content change in iPhone
    text
    copied!<p>hello friends I have created custom table and add all needed delegate and datasource for table then this is working good but when we scroll my table then content change like this is code...</p> <pre><code>Table_worklist=[[UITableView alloc]initWithFrame:CGRectMake(10,480,750,130)style:UITableViewStylePlain]; Table_worklist.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; Table_worklist.delegate=self; Table_worklist.dataSource=self; Table_worklist.layer.borderWidth = 2.0; Table_worklist.layer.borderColor = [UIColor grayColor].CGColor; [ScrollView addSubview:Table_worklist]; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell== nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] ; cell.selectionStyle = UITableViewCellSelectionStyleNone; UITextField *resultval=[[UITextField alloc]initWithFrame:CGRectMake(510,10,120,30)]; resultval.tag=1; resultval.font = [UIFont boldSystemFontOfSize:12.0]; //the horizontal alignment of the text resultval.textAlignment = NSTextAlignmentCenter; resultval.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter; resultval.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right resultval.delegate =self; if([[NSString stringWithFormat:@"%@",[[TestSample objectAtIndex:indexPath.row]valueForKey:@"ResultType"]]isEqualToString:@"Numerical"]) { imageLayer = field.layer; [imageLayer setCornerRadius:02]; [imageLayer setBorderWidth:1]; imageLayer.borderColor=[[UIColor lightGrayColor]CGColor]; } else if([[NSString stringWithFormat:@"%@",[[TestSample objectAtIndex:indexPath.row]valueForKey:@"ResultType"]]isEqualToString:@"Words"]||[[NSString stringWithFormat:@"%@",[[TestSample objectAtIndex:indexPath.row]valueForKey:@"ResultType"]]isEqualToString:@"Comment"]) { imageLayer = field.layer; [imageLayer setCornerRadius:06]; [imageLayer setBorderWidth:1]; imageLayer.borderColor=[[UIColor blackColor]CGColor]; UIButton *CheckMark=[[UIButton alloc]initWithFrame:CGRectMake(540,10,30,30)]; CheckMark.tag=1; [CheckMark setImage:[UIImage imageNamed:@"DownTriangle1"]forState:UIControlStateNormal]; imageLayer = CheckMark.layer; [imageLayer setCornerRadius:02]; [imageLayer setBorderWidth:1]; imageLayer.borderColor=[[UIColor blackColor] CGColor]; [cell.contentView addSubview:CheckMark]; } [cell.contentView addSubview:resultval]; } return cell; } </code></pre> <p>this show right data for first 3or4 cell(because table height 130 so show only 3 cell at a time )for these 3 cell my table show right data ...for example </p> <pre><code> if([[NSString stringWithFormat:@"%@",[[TestSample objectAtIndex:indexPath.row]valueForKey:@"ResultType"]]isEqualToString:@"Numerical"]) { } </code></pre> <p>then data is numerical go this if condition other wise go else condition...... but when we have for more cell like as 7-8 cell then when we scroll these cell so what happened suppose at cell-4 my controller go else if condition forComment and word data .........so at last cell -8 got numerical data so controller go in if condition but check mark button which was created in if else condition which show on my if condition data ......so i don't know what happened when we scroll how to change my condition ...... Actually i thing when last created else if condition (which create uibutton checkmark)on cell-4 which are apply on cell-8...........but controller go in right place in if condition at cell-8 .....but last time created checkmark button generated on cell-8 ...... how to solve this problem.... </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload