这可能是一个非常容易解决的问题;我一直在阅读无数的论坛和教程,似乎无法找到答案。
在我的应用程序中,我有一个弹出集合视图来选择特定选项并返回一个值...
但是它不会突出显示或选择?我可以看到 NS 日志输出从不显示选择或数据传递。
这是我的代码...
集合.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