Skip to content

Instantly share code, notes, and snippets.

View hafizrahman's full-sized avatar
🦉

Hafiz Rahman hafizrahman

🦉
View GitHub Profile
View settag example
for (int i = 0; i < 5; i++) {
UICollectionView *currentCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, maxWidth, collectionViewHeight) collectionViewLayout:layout];
// Trick to let the delegate and data source functions deal with the multiple UICollectionView's
[currentCollectionView setTag:i];
}
@hafizrahman
hafizrahman / gist:6835190
Created October 5, 2013 00:54
How to use tag in datasource methods.
View gist:6835190
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
NSInteger collectionID = collectionView.tag;
// do something about the id......
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger collectionID = collectionView.tag;
@hafizrahman
hafizrahman / gist:6835037
Last active December 24, 2015 17:19
Use setTag to as identifier for the UICollectionView objects, which can then be used by delegate and datasource methods.
View gist:6835037
for (int i = 0; i < 5; i++) {
UICollectionView *currentCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, maxWidth, collectionViewHeight) collectionViewLayout:layout];
// Trick to let the delegate and data source functions deal with the multiple UICollectionView's
[currentCollectionView setTag:i];
}