【问题标题】:AQGridView Select CellAQGridView 选择单元格
【发布时间】:2012-06-13 22:38:41
【问题描述】:

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

}

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

【问题讨论】:

    标签: ios aqgridview


    【解决方案1】:

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

    【讨论】:

    • 好的,一个简单的问题。如果我在didSelect...performSegue 但我想在storyID 中使用prepareSegue,我该如何从prepare 方法中获取index
    • 没关系,我决定放弃使用 Segues 并以编程方式完成所有操作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多