Uilabel和Tablecell

时间:2012-04-28 16:14:18

标签: objective-c xcode ios5 uitableview

一个小问题我创建了一个自定义UITablecell,但在单元格中需要解析数据,所以我将IBOutlet UILabel *One;连接到UILabel但是当我正在做

One.text = @“Lorem ......”;错误显示我在mijn viewController中导入了UITablecell.h。

**Use of undeclared identifier 'One'**

/

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

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

            NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"ViewControllerCell" owner:nil options:nil];

            for (UIView *view in views) {
                if([view isKindOfClass:[UITableViewCell class]])
                {
                    cell = (ViewControllerCell*)view;
                }


            }

        }
One.text = @"Lorem...";
            return cell;
    }

2 个答案:

答案 0 :(得分:1)

在这种情况下,您的自定义UITableViewCell课程的实例将为cell,因此您需要像这样访问它

cell.One.text = @"Lorem..";

答案 1 :(得分:0)

首先,您必须将tableViewCell类型化为自定义单元格。

{
  YourCustomCell *objCustomCell=(YourCustomCell *)[tableView cellForRowAtIndexPath:indexPathForThatRow];
  objCustomCell.One.text=@"YourDesiredstringvalue";
}