CPCollectionView : Allow the prototype view to be loaded from a cib

With this commit CPCollectionView can load subviews from an external
cib. Outlets, actions and bindings between the view and the
prototype are restaured when the view is loaded.
This commit is contained in:
cacaodev committed 2012-11-30 14:56:36 +01:00
1 parent 71b93a2b4c
commit 8b5c0fb715
2 files changed
+27 -7

No files matched your search

+1 -7
View File
@@ -206,13 +206,7 @@
item = _cachedItems.pop();
else
{
if (!_itemData)
if (_itemPrototype)
_itemData = [CPKeyedArchiver archivedDataWithRootObject:_itemPrototype];
item = [CPKeyedUnarchiver unarchiveObjectWithData:_itemData];
}
item = [_itemPrototype copy];
[item setRepresentedObject:anObject];
[[item view] setFrameSize:_itemSize];
+26
View File
@@ -29,6 +29,32 @@
@implementation CPCollectionViewItem : CPViewController
{
BOOL _isSelected;
CPData _cachedArchive;
}
- (id)copy
{
var cibName = [self cibName],
copy;
if (cibName)
{
copy = [[[self class] alloc] initWithCibName:cibName bundle:[self cibBundle]];
}
else
{
if (!_cachedArchive)
_cachedArchive = [CPKeyedArchiver archivedDataWithRootObject:self];
copy = [CPKeyedUnarchiver unarchiveObjectWithData:_cachedArchive];
// copy connections
}
[copy setRepresentedObject:[self representedObject]];
[copy setSelected:[self isSelected]];
return copy;
}
// Setting the Represented Object