1

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?

ChrisP
  • 9,796
  • 21
  • 77
  • 121

3 Answers3

1

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.

pasawaya
  • 11,515
  • 7
  • 53
  • 92
mackworth
  • 5,873
  • 2
  • 29
  • 49
  • The gridview is created programmatically in the view controller. – ChrisP Jun 24 '11 at 00:41
  • Sorry to be picky, but have you checked with the debugger or NSLog that self.gridView is a valid AQGridView at the point you're calling reloadData? There's no delegate concept at that point, just a straight method call. If it's valid, then there's no way that [x y] doesn't call the method y of object x. – mackworth Jun 24 '11 at 15:54
0

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

}
Daniel
  • 23,129
  • 12
  • 109
  • 154
prediv
  • 1
  • 2
0

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];
}
RobCroll
  • 2,571
  • 1
  • 26
  • 36