iOS Xcode - 分组TableView分隔线显示

标签 ios xcode separator uitableview

我是唯一遇到这个问题的人吗?

对于注册页面,我在分组 TableView 中只有几个部分和几行。当我上下滑动页面时,两个单元格之间出现奇怪的分隔粗线。有些细胞像被挤压一样下沉。这是 iOS 5.0 的错误吗?为了这个小问题我已经工作了3天了。请帮忙!

我已经尝试

self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

self.tableView.separatorColor = [UIColor lightGrayColor];

它们都不起作用。

[已编辑]

Paul Peelen 你是对的,我知道你的意思,但我不知道继续前进。在我评论“if(cell == nil)”之前,一切都与您所说的相同。但是在我评论之后,标签显示良好,并且分隔线不再有问题,但是当我将文本插入文本字段并向下滑动并再次向上滑动时,文本字段的文本消失并被刷新。我该如何解决这个问题? 下面是我的代码:

- (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;

}

最佳答案

您想要分隔符颜色吗?如果没有,您可以随时将其设置为清除。

self.tableView.separatorColor = [UIColor clearColor];

关于iOS Xcode - 分组TableView分隔线显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10428161/

相关文章:

javascript - 为用户替换网站上的千位分隔符

javascript - 增强千位分隔符的正则表达式?

ios - 使用 CSS3 动画,iPad 2 的性能是否优于 iPad 1?

ios - 与 "iOS 9 simulator"失去连接

ios - 当我只指定一个约束时自动布局约束冲突

ios - 在 Swift 中生成多页 PDF

xcode - didSelectRowAtIndexPath 中的详细信息项显示为 null

iphone - iOS 中基于 URL 的导航,例如 three20 的 TTNavigator

xcode - 多个 git 帐户不适用于 Xcode

python - 在 Python 中乘以字符串时使用 sep