奇怪的UITableViewCell加载异常 [英] Weird UITableViewCell Loading Exception

查看:93
本文介绍了奇怪的UITableViewCell加载异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用自定义NIB加载我的UITableViewCells。 NIB的文件所有者设置为该类是我的View Controller。然后我将UITableViewCell链接到我放在头文件中的IBOutlet。这一切都正常,直到所有的突然停止工作,并得到这个错误:

In my app, I use a custom NIB to load my UITableViewCells. The NIB's File's Owner is set so the class is my View Controller. I then Link the UITableViewCell to the IBOutlet I put in the header file. It was all working fine, until all of the sudden it stopped working, and gets this error:

uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (UITableViewCellContentView)'

我已经将此异常追溯到[NSBundle loadNibNamed:owner:options:]

I have traced this exception to [NSBundle loadNibNamed:owner:options:]

static NSString *CellIdentifier = @"SubjectCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"SubjectCell" owner:self options:NULL];
cell = customSubjectCell;

我已经尝试过这两个设备和模拟器,但都得到相同的错误。我今天下载了新的SDK,我认为可能是造成这种情况。

I have tried this on two devices and the simulator, but all get the same error. I downloaded the new SDK today, and I think that may have caused this.

请注意: strong>

PLEASE NOTE:

此问题已过时,下面的修复是一个临时修复。苹果已经修复了SDK,所以如果你有最新版本的SDK,这个不适用于你。

This question is outdated, and the fix below was a temporary fix. Apple has fixed its SDK, so if you have the newest version of the SDK this does not apply to you.

推荐答案

在开发论坛中找到解决方案

Found solution in dev forums

创建此文件:

UITableViewCellContentView.h

UITableViewCellContentView.h

#import <UIKit/UIKit.h>
@interface UITableViewCellContentView : UIView {
}
@end

UITableViewCellContentView.m

UITableViewCellContentView.m

#include "UITableViewCellContentView.h"
@implementation UITableViewCellContentView

+ (id)alloc {
    return [UIView alloc];
}

+ (id)allocWithZone:(NSZone *)zone {
    return [UIView allocWithZone:zone];
}

@end

这篇关于奇怪的UITableViewCell加载异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆