通過在UICollectionView和UIViewController實現多行多列單元格效果
Voltron通過在UICollectionView和UIViewController實現多行多列單元格效果。既可以接收單個單元格手勢事件,也可以接受一組單元格的手勢事件。
UICollectionView
with UIViewController
s instead of cells.
View controller containment compliant!
Installation
Voltron is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Voltron", '~> x.x.x'
Usage
To run the example project, clone the repo, and run pod install
from the Example directory first.
-
#import <Voltron/Voltron.h>
-
Use
WMLCollectionView
instead ofUICollectionView
andWMLCollectionViewCell
for cells, displaying view controllers. -
Set the
collectionView.containerViewController
to the view controller that is hosting children view controllers. -
Implement a data source method:
- (UIViewController *)collectionView:(WMLCollectionView *)collectionView controllerForIdentifier:(NSString *)identifier { if ([identifier isEqualToString:@"Login"]) { return [self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"]; } else if ([identifier isEqualToString:@"Profile"]) { return [self.storyboard instantiateViewControllerWithIdentifier:@"UserProfileViewController"]; } }
- Once done displaying cell, call
didEndDisplayingCell:
passing the cell to give the collection view a clue that it can be recycled.
- (void)collectionView:(WMLCollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { [collectionView didEndDisplayingCell:cell]; }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!