UICollectionview ermöglicht die Mehrfachauswahl nicht funktioniert xcode
So wählen Sie die Collection View
Zelle-Bilder verwenden ermöglicht die Mehrfachauswahl funktioniert nicht. Bitte schlagen Sie mich Idee oder links
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"photo viewer");
[self.collectionView setPagingEnabled:NO];
self.collectionView.allowsSelection=YES;
[self.collectionView registerClass:[CWPhotoGalleryCell class]
forCellWithReuseIdentifier:CWPhotoGalleryCellIdentifier];
[self.collectionView scrollToItemAtIndexPath:self.selectedIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:YES];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:
(NSInteger)section
{
return [self.imageArray count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CWPhotoGalleryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CWPhotoGalleryCellIdentifier
forIndexPath:indexPath];
cell.navigationControllerContainer = self.navigationController;
ALAsset *photo = [self.imageArray objectAtIndex:indexPath.row];
ALAssetRepresentation *rep = [photo defaultRepresentation];
CGImageRef ref = [rep fullScreenImage];
UIImage *img = [[UIImage alloc] initWithCGImage:ref];
cell.image = img;
NSLog(@"clicked");
return cell;
}
-(CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return self.view.bounds.size;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
Du musst angemeldet sein, um einen Kommentar abzugeben.
Wählen Sie einzelne oder mehrere Elemente in der Sammlung anzeigen, die Sie implementieren müssen UIColectionViewDelegate. Sie müssen auch hinzufügen NSMutableArray, wo Sie halten ausgewählte Elemente (selectedItems).
Das Letzte, was Links zu tun, ist die Schaltfläche hinzufügen, um Toggle zwischen ausgewählten und nicht-ausgewählten Zustand:
Hoffe, dass dies helfen.