ios - AQGridView选择单元格

标签 ios aqgridview

我创建一个自定义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);

}

如何在storyID中访问cell中的gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index

最佳答案

将您的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);
}

关于ios - AQGridView选择单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11024353/

相关文章:

objective-c - 导航 Controller 标题

ios - 使用自动布局推送时使用隐藏按钮时约束更新导致项目移动

ios - 我可以在 Objective-C 中获取 Markdown 文件的内容吗?

iphone - UIView:没有性能问题的圆角

IOS- AQGridView 中的 viewheaderInSection

objective-c - GridView:如何调整 UI GridView 单元格边距

ios - 如何在monotouch应用程序下下载和更新本地镜像

ios - SceneKit 在不动时下降到 30FPS

ios - 带有网格轮廓的 AQGridView

iphone - 调用 MyAppDelegate.m 中的方法到 ViewController