AQGridview不调用数据源方法
我正在尝试基于 /examples 文件夹中的 ImageDemo 实现 AQGridView 。我有一个具有以下声明的视图控制器:
@interface ImageDemoViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource, ImageDemoCellChooserDelegate>
{
...
我的视图控制器中没有任何数据源方法
- (NSUInteger) numberOfItemsInGridView: (AQGridView *) aGridView
{
return ( [images count] );
}
被调用。这是我设置 gridview 的地方,使我的视图控制器成为 gridview 的委托。
- (void)viewDidLoad
{
[super viewDidLoad];
self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.gridView.autoresizesSubviews = YES;
self.gridView.delegate = self;
self.gridView.dataSource = self;
images=[[NSMutableArray alloc]init];
[images addObject:@"http://t3.gstatic.com/images?q=tbn:ANd9GcTOXAzFMoK441mcn9V0OemVe_dtAuCpGjBkLrv4rffyOjYIo45BEw"];
[self.gridView reloadData];
}
如果我设置断点,
[self.gridView reloadData];
就会执行该行,但不会调用 AQGridView 中的 reloadData 方法。与 ImageDemo 的唯一区别是我没有视图控制器的 .xib 文件。我是否忘记连接某些东西,导致数据源方法未被调用?
I am trying to implement AQGridView based upon the ImageDemo in the /examples folder. I have a view controller with the following declaration:
@interface ImageDemoViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource, ImageDemoCellChooserDelegate>
{
...
None of the datasource methods in my view controller such as
- (NSUInteger) numberOfItemsInGridView: (AQGridView *) aGridView
{
return ( [images count] );
}
are being called. Here is where I setup the gridview making my view controller the delegate for the gridview.
- (void)viewDidLoad
{
[super viewDidLoad];
self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.gridView.autoresizesSubviews = YES;
self.gridView.delegate = self;
self.gridView.dataSource = self;
images=[[NSMutableArray alloc]init];
[images addObject:@"http://t3.gstatic.com/images?q=tbn:ANd9GcTOXAzFMoK441mcn9V0OemVe_dtAuCpGjBkLrv4rffyOjYIo45BEw"];
[self.gridView reloadData];
}
If I set a breakpoint on
[self.gridView reloadData];
the line is executed but reloadData method in AQGridView is not called. The only difference from the ImageDemo is I do not have a .xib file for the view controller. Have I forgotten to hook up something, resulting in the datasource methods not being called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果没有 XIB,那么谁来创建 gridView?如果它从未被创建,那么它将是 NIL,并且您将具有您所描述的行为。 (如果是这样,那么只需添加:
self.gridview = [AQGridView alloc] initWithFrame: ...];
应该足够了。If there's no XIB, then who's creating the gridView? If it's never created, then it would be NIL, and you'd have the behavior you describe. (If that's it, then just adding:
self.gridview = [AQGridView alloc] initWithFrame: ...];
should suffice.有同样的问题。通过用 AQGridView替换视图来解决。
[self.view addSubview:self.gridView]完整方法:
Had the same problem. Solved by replacing the view with the AQGridView.
[self.view addSubview:self.gridView]Full method:
也许你可以尝试实现这个:
Maybe you could try implementing this: