0

我正在使用 AQGridView 显示来自 Web 服务的图像。当我触摸一个单元格时,didSelectItemAtIndex不会调用代表。委托被调用,numberOfItemsInGridView所以我想我已经完成了委托和数据源设置。这是代码:

PhotoGridViewController.h

#import "AQGridView.h"
#import "PhotoGridViewCell.h"

@interface PhotoGridViewController : UIViewController<AQGridViewDelegate,AQGridViewDataSource>

@property (nonatomic, strong) NSArray *imageDictionaries;
@property (weak, nonatomic) IBOutlet AQGridView *gridView;
@property (nonatomic, retain) IBOutlet PhotoGridViewCell *gridViewCellContent;

-(void)refreshImages;

@end

PhotoGridViewController.m

#import "PhotoGridViewController.h"
#import "PhotoGridViewCell.h"
#import "AQGridViewCell.h"

@interface PhotoGridViewController ()
@end

@implementation PhotoGridViewController

@synthesize imageDictionaries = _imageDictionaries;  
@synthesize gridView=_gridView;
@synthesize gridViewCellContent = _gridViewCellContent;

... 辅助方法、单元创建和图像获取方法 ...

- (NSUInteger) numberOfItemsInGridView: (AQGridView *) aGridView
{
    return ( [self.imageDictionaries count] );
}

^^^ 这个委托方法称为 ^^^ ...

-(void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {
    NSLog (@"Selected theArgument=%d\n", index);
}

该 NSLog 语句永远不会被调用。我使用这个项目 - http://fdiv.net/2011/10/29/reusable-views-ios - 作为制作我的指南。那个工作得很好。我已经调试了两者,并逐步完成了从启动到触摸单元的每一步,但我无法找出哪里出错了。希望这是我没有看到的显而易见的事情。

编辑:单元格被选中是因为这条线

cell.selectionStyle = AQGridViewCellSelectionStyleGlow;

显示被触摸时的单元格变化。

4

1 回答 1

2

您必须设置委托。我打赌你忘了。

self.gridView.delegate = self;
self.gridView.dataSource = self;
于 2012-05-15T21:04:19.107 回答