由于我无法使用任何框架来创建相册,我正在尝试使用 Collection View 创建自己的相册,但我一开始就被卡住了。
我的目标是将我的网络服务中的所有图像显示到我的集合视图中,因为所有图像都显示了,下一步是当有人点击任何单元格时,我可以在新视图中打开它并在所有图像之间导航。
这是我创建的基本代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[collectionController reloadData];
tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:nil action:@selector(touched)];
tapGesture.numberOfTapsRequired = 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 6;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"Cell";
CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
[cell.imgCollection setImageWithURL:[NSURL URLWithString:@"http://sallescds.com.br/wp-content/uploads/2012/12/xepop-300x300.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
[cell.imgCollection addGestureRecognizer:tapGesture];
return cell;
}
-(void)touched:(UIGestureRecognizer *)tap{
NSLog(@"the touch happened");
}
多谢你们。