1

我像这样创建一个自定义 AQGridViewCell:

- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index
{
static NSString * PlainCellIdentifier = @"PlainCellIdentifier";

GridViewCell * cell = (GridViewCell *)[aGridView dequeueReusableCellWithIdentifier:@"PlainCellIdentifier"];

if ( cell == nil )
{
    cell = [[GridViewCell alloc] initWithFrame: CGRectMake(3.333, 3.3336, 100, 100)
                               reuseIdentifier: PlainCellIdentifier];
}
NSString *stringURL = [[featuredStories objectAtIndex:index] objectAtIndex:1];
NSLog(@"stringURL: %@", stringURL);
NSURL *url = [NSURL URLWithString:stringURL];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"example0.png"]];
cell.storyID = [[featuredStories objectAtIndex:index] objectAtIndex:0];
return cell;
}

当您像这样选择单元格时,我已经添加了该方法:

- (void) gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {

//I want to NSLog the cell.storyID here
NSLog (@"Selected theArgument=%d\n", index);

}

我如何去访问in storyIDthe cellin gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index

4

1 回答 1

3

将您更新didSelectItemAtIndex为以下内容

- (void) gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {

    //Get the cell at the selected index
    GridViewCell * cell = (GridViewCell *)[grid cellForItemAtIndex:index];
    NSLog(@"Story Id = %@", cell.storyID);
}
于 2012-06-13T23:24:54.223 回答