我在我的应用程序中使用PSUICollectionView,其中与图像大拇指画廊加载水平滚动视图。 现在我需要两个更多的collectionviews(画廊)来显示两种其他类型的图片。在ios中的同一屏幕上的多个collectionviews
任何人都可以请帮我吗? 在此先感谢。
我在我的应用程序中使用PSUICollectionView,其中与图像大拇指画廊加载水平滚动视图。 现在我需要两个更多的collectionviews(画廊)来显示两种其他类型的图片。在ios中的同一屏幕上的多个collectionviews
任何人都可以请帮我吗? 在此先感谢。
简单。像添加其他UIView一样添加视图。正确设置框架,他们应该工作。
为每个人保留一个插座,然后你可以检查他们中哪一个正在调用委托/数据源方法。
我把它加在委托和数据源方法的一些代码行如下工作 -
// setting tag
[self.imageCollection setTag:1];
[self.finishImageCollection setTag:2];
[self.prevImageCollection setTag:3];
- (NSString *)formatIndexPath:(NSIndexPath *)indexPath {
return [NSString stringWithFormat:@"%ld", (long)indexPath.row+1];
}
// Populating cells
- (PSUICollectionViewCell *)collectionView:(PSUICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ImageGridCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
if(collectionView.tag==1){
cell.statusImage.image= [UIImage imageNamed:@"checked.png"];
cell.imageThumb.image = [self.startImages objectAtIndex:indexPath.row];
}
if(collectionView.tag==2){
cell.statusImage.image= [UIImage imageNamed:@"checked.png"];
cell.imageThumb.image = [self.finishImages objectAtIndex:indexPath.row];
}
if(collectionView.tag==3){
cell.statusImage.image= [UIImage imageNamed:@"checked.png"];
cell.imageThumb.image = [self.prevImages objectAtIndex:indexPath.row];
}
return cell;
}
- (NSInteger)collectionView:(PSUICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
int imgCount;
if(collectionView.tag==1)
{
[self loadStartPictures];
imgCount=self.startImages.count;
}
if(collectionView.tag==2)
{
[self loadFinishPictures];
imgCount=[self.finishImages count];
}
if(collectionView.tag==3)
{
[self loadSupervisorPictures];
imgCount=[self.prevImages count];
}
return imgCount;
}
#pragma mark -
#pragma mark Collection View Delegate
- (void)collectionView:(PSTCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
self.allImages=[[NSMutableArray alloc]init];
UIImage *imageAtIndexPath;
NSLog(@"Delegate cell %@ : SELECTED", [self formatIndexPath:indexPath]);
ImageGridCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.label.backgroundColor=[UIColor underPageBackgroundColor];
if(collectionView.tag==1){
imageAtIndexPath=[self.startImages objectAtIndex:indexPath.row];
}
if(collectionView.tag==2){
imageAtIndexPath=[self.finishImages objectAtIndex:indexPath.row];
}
if(collectionView.tag==3){
imageAtIndexPath=[self.supervisorImages objectAtIndex:indexPath.row];
}
}
我无需任何条件立即需要全部三个收集视图。所以他们都必须立即调用委托/数据源方法。我如何实现? – Arun 2013-04-06 06:23:19
在您的代理/数据源方法中,检查查看哪个对象正在询问并返回相应的信息。 – Undo 2013-04-06 13:26:39
你可否请给我一个数据源/委托方法的例子多个集合视图?我认为没有必要实施委托方法,因为我只想显示图像并且不需要为每个单元格执行操作。 – Arun 2013-04-08 06:35:29