AQGridview不调用数据源方法

发布于 2024-11-06 04:59:23 字数 1086 浏览 1 评论 0原文

我正在尝试基于 /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

对岸观火 2024-11-13 04:59:23

如果没有 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.

咋地 2024-11-13 04:59:23

有同样的问题。通过用 AQGridView替换视图来解决。
[self.view addSubview:self.gridView]

 self.view = self.gridView;

完整方法:

- (void) viewDidLoad
{
    [super viewDidLoad];

    self.gridView = [[AQGridView alloc] init];
    self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    self.gridView.autoresizesSubviews = YES;
    self.gridView.delegate = self;
    self.gridView.dataSource = self;

    self.view = self.gridView;

    [self.gridView reloadData];
}

Had the same problem. Solved by replacing the view with the AQGridView.
[self.view addSubview:self.gridView]

 self.view = self.gridView;

Full method:

- (void) viewDidLoad
{
    [super viewDidLoad];

    self.gridView = [[AQGridView alloc] init];
    self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    self.gridView.autoresizesSubviews = YES;
    self.gridView.delegate = self;
    self.gridView.dataSource = self;

    self.view = self.gridView;

    [self.gridView reloadData];
}
故事和酒 2024-11-13 04:59:23

也许你可以尝试实现这个:

- (void)LoadSearch
{
    NSURL *test1 = [NSURL URLWithString:@"http://www.4ddraws.com/search_iphone.asp"];
    NSURLRequest *test = [NSURLRequest requestWithURL:test1];
    [web4D setScalesPageToFit:(YES)];
    [web4D loadRequest:test];

}

Maybe you could try implementing this:

- (void)LoadSearch
{
    NSURL *test1 = [NSURL URLWithString:@"http://www.4ddraws.com/search_iphone.asp"];
    NSURLRequest *test = [NSURLRequest requestWithURL:test1];
    [web4D setScalesPageToFit:(YES)];
    [web4D loadRequest:test];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文