I'm using AQGridView to display images from a web service. When I touch a cell, the didSelectItemAtIndex
delegate is not called. The numberOfItemsInGridView
delegate is called, so I think I've got my delegates and datasource setup. Here's the code:
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;
... helpers methods, cell creation, and image fetching methods ...
- (NSUInteger) numberOfItemsInGridView: (AQGridView *) aGridView
{
return ( [self.imageDictionaries count] );
}
^^^ This delegate method is called ^^^ ...
-(void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {
NSLog (@"Selected theArgument=%d\n", index);
}
That NSLog statement is never called. I used this project - http://fdiv.net/2011/10/29/reusable-views-ios - as a guide in making mine. That one works just fine. I've debugged both and stepped through each step from launch to touching on a cell and I can't find out where I'm going wrong. Hopefully this is something obvious that I'm just not seeing.
EDIT: Cells are getting selected because this line
cell.selectionStyle = AQGridViewCellSelectionStyleGlow;
shows the cell change when it gets touched.
You have to set the delegate. I bet you forget.
self.gridView.delegate = self;
self.gridView.dataSource = self;