我有一個應用程序需要兩個獨立的圖像庫。我已經使用UICollectionView完成了第一個。我已經設置了一切,以便UICollectionView完美工作,我只是希望能夠點擊每個圖像以全屏查看它們。我還想知道如何在不同圖像的不同頁面上構建第二個UICollectionView。是否就像製作第二個UICollectionView並將其命名爲myCollectionView2一樣簡單,並且與Image Arrays一樣?UICollectionView中的圖像點擊進入全屏
這是我現在有第一個集合代碼:
#import "CollectionViewController.h"
#import "CustomCell.h"
@interface CollectionViewController()
{
NSArray *ArrayOfImages;
}
@end
@implementation CollectionViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[self myCollectionView1]setDataSource:self];
[[self myCollectionView1]setDelegate:self];
ArrayOfImages = [[NSArray alloc] initWithObjects:@"MacLeodsAccessories.png", @"MacleodsBag.png", @"MacleodsBag1.png", @"MacleodsBag2.png", @"MacleodsCollar.png", @"MacleodsCushions.png", @"MacleodsPurse.png", @"MacleodsTeaAndCoffee.png", nil];
}
//datasource and delegate method
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [ArrayOfImages count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomCell *cell =[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
[[cell myImage]setImage: [UIImage imageNamed:[ArrayOfImages objectAtIndex:indexPath.item]]];
這可能是編碼都是錯誤的,並很可能是多餘的,但還是可能正是我需要的,我只是不知道如何糾正它,以及我在這裏放置什麼,這將使這項工作。
[[cell myImage]setGestureRecognizers:[ArrayOfImages objectAtIndex:indexPath.item]];
return cell;
}
如果有人可以幫忙,我會很感激。 在此先感謝。