0

これはおそらく非常に簡単な修正です。無数のフォーラムやチュートリアルを読んでいますが、答えが見つからないようです。

私のアプリでは、特定のオプションを選択して値を返すポップオーバーコレクションビューがあります...

ただし、強調表示または選択されませんか? NS ログ出力に選択またはデータパスが表示されないことがわかります。

これが私のコードです...

collection.h ファイル

@interface collection : UICollectionViewController <UICollectionViewDataSource,     UICollectionViewDelegate>

@property (nonatomic, retain) NSArray  *counterImages;
@property (nonatomic, retain) NSArray  *descriptions;
@property (nonatomic, weak)   UILabel *graniteselect;
@property (nonatomic, retain) UIPopoverController* _collectionPopOver;
@property (nonatomic) BOOL clearsSelectionOnViewWillAppear; // defaults to YES, and if    YES, any selection is cleared in viewWillAppear:
@property (nonatomic) BOOL allowsSelection;

@end


implementation file:



#pragma mark UICollectionViewDataSource

-(NSInteger)numberOfSectionsInCollectionView:
(UICollectionView *)collectionView
{
return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return _descriptions.count;

}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
             cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *myCell = [collectionView
                                dequeueReusableCellWithReuseIdentifier:@"MyCell"
                                forIndexPath:indexPath];

UIImage *image;
int row = [indexPath row];

image = [UIImage imageNamed:_counterImages[row]];

myCell.imageView.image = image;

myCell.celltext.text= [_descriptions objectAtIndex:row];

return myCell;

}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action        forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
_graniteselect.text = [_descriptions objectAtIndex:row];
 [self._collectionPopOver dismissPopoverAnimated:YES];

NSLog(@"Setting Value for Granite Select");

}

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:    (NSIndexPath *)indexPath {
// TODO: Deselect item
}



-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
RoleDetailTVC *destination =
[segue destinationViewController];

destination.graniteselect = _graniteselect;

NSLog(@"Passing Data to RoleDetailTVC");

}
@end
4

1 に答える 1