cellForRowAtIndexPath 中非常奇怪的问题

发布于 2024-12-26 06:42:09 字数 657 浏览 2 评论 0原文

我真的不明白为什么我在分配 NSArray *topLevelObjects 的行中得到“EXC_BAD_ACCESS”。这太疯狂了,因为我在另一个 tabliView 中使用完全相同的代码和相同的 BlogCell,而且它运行得很好!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int r = indexPath.row;
    static NSString *CellIdentifier = @"Blog";
    BlogCell *cell = (BlogCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"BlogCell" owner:self options:nil];
        cell = [topLevelObjects objectAtIndex:0];  
    }        

    return cell;
}

I really can't understand why i get a "EXC_BAD_ACCESS" in the line where I assign NSArray *topLevelObjects. It's crazy because I use exactly the same code and the same BlogCell in another tabliView, and there it's working perfectly!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int r = indexPath.row;
    static NSString *CellIdentifier = @"Blog";
    BlogCell *cell = (BlogCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"BlogCell" owner:self options:nil];
        cell = [topLevelObjects objectAtIndex:0];  
    }        

    return cell;
}

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

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

发布评论

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

评论(1

四叶草在未来唯美盛开 2025-01-02 06:42:09

确保您在 BlogCell 到 FilesOwner 中指定的所有出口在此类中都有相应的 IBOutlet。

Make sure all the outlets you specify in BlogCell to FilesOwner have corresponding IBOutlets in this class.

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