我使用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;
@endPhotoGridViewController.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;显示单元格在被触摸时发生的变化。
发布于 2012-05-15 21:04:19
你必须设置代表。我打赌你忘了。
self.gridView.delegate = self;
self.gridView.dataSource = self;https://stackoverflow.com/questions/10608748
复制相似问题