ELCTextfieldCells를 사용하는 UITableView로 앱을 만들고 있습니다. 일부 셀의 경우 UISegmentedControl을 설정하고 UITextField를 비활성화합니다. 그래서 여기 내가 그 jQuery과에 밀어 때 무엇을 얻을의 스크린 샷이다 "천개의 단어가 그림에 가치가있다"UITableView의 UISegmentedControl의 이상한 동작
그리고 화면에서 해당 셀을 이동하고 다시 퍼팅 후
(기본적으로 다시로드)
- UISegmentedControl는 vi가되지 않습니다
그래서이 문제가 있습니다 : 나는 다음과 같은 수 뷰가 처음으로 나타날 때 sible;
- 해당 UISegmentedControl의 값은 맨 위에있는 셀에 기록됩니다.
어쨌든이 세포에 영향을 미치는 일부 코드 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[self.tableViewCellValues objectAtIndex:indexPath.row]rangeOfString:@"Gender"].location != NSNotFound || [[self.tableViewCellValues objectAtIndex:indexPath.row]rangeOfString:@"Still Active Employee"].location != NSNotFound) {
static NSString *CellIdentifier = @"CellWithSegmentedControl";
ELCTextfieldCell *cell = (ELCTextfieldCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[ELCTextfieldCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[self configureCell:cell atIndexPath:indexPath];
UISegmentedControl *segmentedControl;
if ([cell.leftLabel.text rangeOfString:@"Gender"].location != NSNotFound) {
segmentedControl = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"Male", @"Female", nil]];
} else {
segmentedControl = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"Yes", @"No", nil]];
}
segmentedControl.frame = CGRectMake(215, 6, cell.rightTextField.frame.size.width, cell.rightTextField.frame.size.height - 10);
segmentedControl.tag = 26;
[segmentedControl addTarget:self action:@selector(segmentedControlHasChangedValue:) forControlEvents:UIControlEventValueChanged];
UIFont *font = [UIFont boldSystemFontOfSize:12.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont];
[segmentedControl setTitleTextAttributes:attributes forState:UIControlStateNormal];
[cell addSubview:segmentedControl];
[cell bringSubviewToFront:segmentedControl];
cell.rightTextField.text = @"";
cell.rightTextField.enabled = NO;
return cell;
}
//checks and other stuff for other cells
}
-(void)segmentedControlHasChangedValue:(id)sender {
NSLog(@"Nothing implemented here yet");
}
가 나는 문제를 해결할 수있는 방법에 어떤 도움을 크게 감상 할 수있다.
는 당신에게 감사
아마 세포를 재사용 할 때의 문제입니다. [이] (http://stackoverflow.com/a/9598341/641062) 도움이 될 것입니다. – Vignesh