我正在尝试将a UILabel与IBOutlet我班级中的创建链接起来.
我的应用程序崩溃,出现以下错误.这是什么意思?我该如何解决?
***由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]:此类不是密钥XXX的密钥值编码.
我正在使用ARC专门为iOS 5开发.应该IBOutlets UIView(和子类)是strong或weak?
下列:
@property (nonatomic, weak) IBOutlet UIButton *button;
Run Code Online (Sandbox Code Playgroud)
将摆脱所有这一切:
- (void)viewDidUnload
{
// ...
self.button = nil;
// ...
}
Run Code Online (Sandbox Code Playgroud)
这样做有什么问题吗?模板正在使用strong,当从"Interface Builder"编辑器直接连接到标题时创建的自动生成属性,但为什么?在UIViewController已经有一个strong到其基准view保留其子视图.
cocoa-touch objective-c interface-builder ios automatic-ref-counting
我正在使用一个UICollectionViewFlowLayout允许重新排序单元格的自定义子类.源代码在这里.
我遇到的问题是,尽管注册并使用正确的标识符,我为Collection View创建的nib文件仍未加载.以下是相关的代码段.
这是在视图控制器.m文件中:
- (void)loadView
{
self.reorderLayout = [[LXReorderableCollectionViewFlowLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero
collectionViewLayout:self.reorderLayout];
UINib *nib = [UINib nibWithNibName:@"CatagoryViewCell" bundle:nil];
[self.collectionView registerNib:nib forCellWithReuseIdentifier:@"CatagoryViewCellID"];
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
Catagory *c = [[[CatagoryStore defaultStore] allCatagories]
objectAtIndex:[indexPath item]];
CatagoryViewCell *cell = (CatagoryViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CatagoryViewCellID" forIndexPath:indexPath];
[cell setController:self];
[[cell nameLabel] setText:c.title];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
这是我引用笔尖的唯一两个地方.
这是单元格笔尖:

这就是它在模拟器和设备中的样子:

我尝试使用类似的代码和原始UICollectionViewFlowLayout类,它工作正常.非常感谢任何见解!
iphone xcode objective-c uicollectionview uicollectionviewcell