正确使用可重用的UITableViewCell

时间:2013-10-06 09:43:53

标签: uitableview

我正在尝试构建一个使用可重用UITableViewCells的应用程序。在我的第一个UITableView中,一切正常,但现在,在我的第二个表中,我无法使用可重复使用的UITableViewCell,Cell只是保持空白。以下是我的配置:

1;我创建了一个UITableViewCell类

2;我将UITableViewCell链接到我在第一步中创建的服装UITableViewClass

3;我将“重用标识符”设置为Cell1

4;我在可重用的UITableViewCell

中添加了一些内容

5;我将服装UITableViewCell类导入到我的UIViewController

6;我将标准UITableView代码添加到我的UIViewController:<UITableViewDataSource, UITableViewDelegate>@property (weak, nonatomic) IBOutlet UITableView *tableview;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

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

    AppDetailCell1 *cell1 = [tableView dequeueReusableCellWithIdentifier:costumeCell1];

    if (!cell1) {
        cell1 = [[AppDetailCell1 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:costumeCell1];
    }

    cell1.appIconImageView.image = self.appIcon;
    cell1.detailAppNameTextView.text = self.detailAppName;
    cell1.developerLabel.text = [NSString stringWithFormat:@"By %@", self.appDeveloper];

    return cell1;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

7;我构建了项目,但我只能找到一个空白的UITableView

我使用与其他UIViewController中的其他可重用TableViewCell相同的方式制作它。

任何人都知道如何解决我的问题?

0 个答案:

没有答案
相关问题