Skip to content

Instantly share code, notes, and snippets.

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 Oct 5, 2013
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 Dec 24, 2015
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];
}