0

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

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 的方法来完成它。

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

4

0 回答 0