我是唯一遇到这个问题的人吗?
我在分组表视图中有几个部分和几行,用于注册页面。当我上下滑动页面时,两个单元格之间出现奇怪的分隔粗线。一些细胞像被压一样下沉。这是 iOS 5.0 的错误吗?我已经为这个小问题工作了 3 天。请帮忙!
我试过
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
和
self.tableView.separatorColor = [UIColor lightGrayColor];
它们都不起作用。
[已编辑]
Paul Peelen 你是对的,我知道你的意思,但我没有继续前进的知识。在我评论“if(cell == nil)”之前,一切都和你说的一样。但是在我评论它之后,标签显示得很好,分隔线不再有问题,但是当我将文本插入textField并向下滑动并再次向上滑动时,textField的文本消失并被刷新。我该如何解决这个问题?下面是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"LabelCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//Here's the problem!
if(cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UILabel *keyLbl = [[UILabel alloc] initWithFrame:CGRectMake(15, 8, 100, 30)];
keyLbl.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:15.0];
keyLbl.textColor = [UIColor colorWithRed:0.275 green:0.275 blue:0.275 alpha:0.9];
keyLbl.backgroundColor = [UIColor clearColor];
valTxtField = [[UITextField alloc] initWithFrame:CGRectMake(120, 5, 180, 30)];
valTxtField.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:18.0];
valTxtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
valTxtField.delegate = self;
valTxtField.returnKeyType = UIReturnKeyDone;
valTxtField.autocorrectionType = UITextAutocorrectionTypeNo;
valTxtField.autocapitalizationType = UITextAutocapitalizationTypeNone;
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
keyLbl.text = NSLocalizedString(@"REGIS_EMAIL", nil);
email_TextField = valTxtField;
}
else if(indexPath.row == 1)
{
keyLbl.text = NSLocalizedString(@"REGIS_RE_EMAIL", nil);
reEmail_TextField = valTxtField;
}
else if(indexPath.row == 2)
{
keyLbl.text = NSLocalizedString(@"REGIS_PWD", nil);
password_TextField = valTxtField;
valTxtField.secureTextEntry = YES;
}
else if(indexPath.row == 3)
{
keyLbl.text = NSLocalizedString(@"REGIS_RE_PWD", nil);
rePassword_TextField = valTxtField;
valTxtField.secureTextEntry = YES;
}
}
else if(indexPath.section == 1)
{
if(indexPath.row == 0)
{
keyLbl.text = NSLocalizedString(@"REGIS_FIRSTNAME", nil);
firstName_TextField = valTxtField;
}
if(indexPath.row == 1)
{
keyLbl.text = NSLocalizedString(@"REGIS_LASTNAME", nil);
lastName_TextField = valTxtField;
}
if(indexPath.row == 2)
{
keyLbl.text = NSLocalizedString(@"REGIS_POSTCODE", nil);
postCode_TextField = valTxtField;
}
if(indexPath.row == 3)
{
keyLbl.text = NSLocalizedString(@"REGIS_GENDER", nil);
gender_TextField = valTxtField;
}
if(indexPath.row == 4)
{
keyLbl.text = NSLocalizedString(@"REGIS_DOB", nil);
DOB_TextField = valTxtField;
}
if(indexPath.row == 5)
{
keyLbl.text = NSLocalizedString(@"REGIS_MOBILE", nil);
mobile_TextField = valTxtField;
}
}
[cell addSubview:keyLbl];
[cell addSubview:valTxtField];
[keyLbl release];
[valTxtField release];
return cell;
}