Permalink
Browse files

[collections] More renaming and register cells.

  • Loading branch information...
jverkoey committed Mar 28, 2013
1 parent cf6572c commit 0a2a9c6db2f8156f5882efc27c53c68c454920f6
@@ -64,7 +64,7 @@ _model.delegate = (id)[NICollectionViewCellFactory class];
atIndexPath:(NSIndexPath *)indexPath
withObject:(id)object {
UICollectionViewCell* cell = [NICollectionViewCellFactory collectionViewModel:collectionViewModel
- cellForCollectionView:tableView
+ cellForCollectionView:collectionView
atIndexPath:indexPath
withObject:object];
if (nil == cell) {
@@ -139,26 +139,26 @@ _model.delegate = (id)[NICollectionViewCellFactory class];
/**
* Asks the receiver to calculate its height.
*
- * The following is an appropiate implementation in your tableView's delegate:
+ * The following is an appropiate implementation in your collectionView's delegate:
*
@code
--(CGFloat)tableView:(UICollectionView *)collectionView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- CGFloat height = tableView.rowHeight;
- id object = [(NICollectionViewModel *)tableView.dataSource objectAtIndexPath:indexPath];
+-(CGFloat)collectionView:(UICollectionView *)collectionView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+ CGFloat height = collectionView.rowHeight;
+ id object = [(NICollectionViewModel *)collectionView.dataSource objectAtIndexPath:indexPath];
id class = [object collectionViewCellClass];
- if ([class respondsToSelector:@selector(heightForObject:atIndexPath:tableView:)]) {
- height = [class heightForObject:object atIndexPath:indexPath tableView:tableView];
+ if ([class respondsToSelector:@selector(heightForObject:atIndexPath:collectionView:)]) {
+ height = [class heightForObject:object atIndexPath:indexPath collectionView:collectionView];
}
return height;
}
@endcode
*
* You may also use the
- * @link NICollectionViewCellFactory::tableView:heightForRowAtIndexPath:model: tableView:heightForRowAtIndexPath:model:@endlink
+ * @link NICollectionViewCellFactory::collectionView:heightForRowAtIndexPath:model: collectionView:heightForRowAtIndexPath:model:@endlink
* methods on NICollectionViewCellFactory to achieve the same result. Using the above example allows you to
* customize the logic according to your specific needs.
*/
-+ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath tableView:(UICollectionView *)collectionView;
++ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath collectionView:(UICollectionView *)collectionView;
@end
@@ -55,6 +55,8 @@ + (UICollectionViewCell *)cellWithClass:(Class)collectionViewCellClass
NSString* identifier = NSStringFromClass(collectionViewCellClass);
+ [collectionView registerClass:collectionViewCellClass forCellWithReuseIdentifier:identifier];
+
cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
// Allow the cell to configure itself with the object's information.
@@ -83,7 +83,7 @@
* If you implement the deletion of the object yourself, your code may resemble the following:
@code
NSArray *indexPaths = [self removeObjectAtIndexPath:indexPath];
-[tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
+[collectionView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
@endcode
*/
- (BOOL)collectionViewModel:(NIMutableCollectionViewModel *)collectionViewModel
@@ -115,7 +115,7 @@ NSIndexSet* indexSet = [self.model addSectionWithTitle:@"New section"];
[self.model addObject:[NITitleCellObject objectWithTitle:@"A cell"]];
// Inform the table view that we've modified the model.
-[self.tableView insertSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
+[self.collectionView insertSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
@endcode
*
* @ingroup TableViewModels
@@ -28,7 +28,6 @@
#import "NICollectionViewModel.h"
#import "NIMutableCollectionViewModel.h"
-#import "NICollectionViewCellBackgrounds.h"
#import "NICollectionViewCellFactory.h"
/**@}*/

0 comments on commit 0a2a9c6

Please sign in to comment.