iPhone:CustomCell,无法设置数据

发布于 2024-11-05 18:32:45 字数 1380 浏览 4 评论 0原文

我尝试使用 Uilabel 和文本字段制作自定义单元格

,我得到了:

-> http://data.imagup.com/9/1119535256.png

但没有给出给定我的值(“Titre”和“Valeur”是通用的):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"InscriptionCustomCell";

InscriptionCustomCell *cell = (InscriptionCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"InscriptionCustomCell" owner:self options:nil];

    for (id currentObject in topLevelObjects){
        if ([currentObject isKindOfClass:[UITableViewCell class]]){
            cell =  (InscriptionCustomCell *) currentObject;
            break;
        }
    }
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;

if(indexPath.section ==0)
{
    [cell.titreCell setText:[model.listModuleInfoPerso objectAtIndex:indexPath.row]];
    [cell.contenuCell setPlaceholder:[model.listModuleInfoPerso objectAtIndex:indexPath.row]];
}else {
    [cell.titreCell setText:[model.listModuleInfoSupp objectAtIndex:indexPath.row]];
    [cell.contenuCell setPlaceholder:[model.listModuleInfoSupp objectAtIndex:indexPath.row]];
}
return cell;

}

没有错误:S,有什么想法吗?

I try to make a custom cell with a Uilabel and textfield

And i get this:

-> http://data.imagup.com/9/1119535256.png

But it's not given given my value ("Titre" & "Valeur" are generic):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"InscriptionCustomCell";

InscriptionCustomCell *cell = (InscriptionCustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"InscriptionCustomCell" owner:self options:nil];

    for (id currentObject in topLevelObjects){
        if ([currentObject isKindOfClass:[UITableViewCell class]]){
            cell =  (InscriptionCustomCell *) currentObject;
            break;
        }
    }
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;

if(indexPath.section ==0)
{
    [cell.titreCell setText:[model.listModuleInfoPerso objectAtIndex:indexPath.row]];
    [cell.contenuCell setPlaceholder:[model.listModuleInfoPerso objectAtIndex:indexPath.row]];
}else {
    [cell.titreCell setText:[model.listModuleInfoSupp objectAtIndex:indexPath.row]];
    [cell.contenuCell setPlaceholder:[model.listModuleInfoSupp objectAtIndex:indexPath.row]];
}
return cell;

}

No error :S, an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

疯到世界奔溃 2024-11-12 18:32:45

将 NSLog 放入 [model.listModuleInfoPerso objectAtIndex:indexPath.row] 中,以便您可以看到输出的内容...

Put an NSLog in the [model.listModuleInfoPerso objectAtIndex:indexPath.row] so you can see what is coming out...

再见回来 2024-11-12 18:32:45

您可能忘记将 Interface Builder 中的标签和文本字段连接到 InscriptionCustomCell 子类中的属性。

You probably forgot to hook up the label and the text field from Interface Builder to the properties in your InscriptionCustomCell subclass.

如痴如狂 2024-11-12 18:32:45

看来您还没有为 UITextField 设置委托。因此,请立即设置委托,然后您就可以访问 TextField 条目。

Here it seems that you haven't set the delegate for UITextField. So, please set delegate now and then you can access the TextField entry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文