UICollectionView

<UICollectionViewDelegate,UICollectionViewDataSource>

delegate & datasource

NSMutableArray *arr1;

arr1 = [NSArray arrayWithObjects:@”angry_birds_cake.jpg”, @”creme_brelee.jpg”, @”egg_benedict.jpg”, @”full_breakfast.jpg”, @”green_tea.jpg”, @”ham_and_cheese_panini.jpg”, @”ham_and_egg_sandwich.jpg”, @”hamburger.jpg”, @”instant_noodle_with_egg.jpg”, @”japanese_noodle_with_pork.jpg”, @”mushroom_risotto.jpg”, @”noodle_with_bbq_pork.jpg”, @”starbucks_coffee.jpg”, @”thai_shrimp_cake.jpg”, @”vegetable_curry.jpg”, @”white_chocolate_donut.jpg”, nil];

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

return arr1.count; }

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

static NSString *striden=@”cell”;

UICollectionViewCell *cell1=[collectionView dequeueReusableCellWithReuseIdentifier:striden forIndexPath:indexPath];

UIImageView *imgvwrecp=(UIImageView *)[cell1 viewWithTag:11];

imgvwrecp.image=[UIImage imageNamed:[arr1 objectAtIndex:indexPath.row]];

cell1.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”photo-frame.png”]];

return cell1; }

Leave a comment