首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AQGridView选择单元格

AQGridView选择单元格
EN

Stack Overflow用户
提问于 2012-06-14 06:38:42
回答 1查看 968关注 0票数 1

我创建了一个自定义AQGridViewCell,如下所示:

代码语言:javascript
复制
- (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;
}

当您选择单元格时,我添加了如下方法:

代码语言:javascript
复制
- (void) gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {

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

}

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-14 07:24:54

将您的didSelectItemAtIndex更新为以下内容

代码语言:javascript
复制
- (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);
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11024353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档