开发者

AQGridview Not Calling Datasource Methods

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,   AQGridVi开发者_高级运维ewDataSource, 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?


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.


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];
}


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];

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜