2012-06-13 4 views
1

создать пользовательские AQGridViewCell так:AQGridView Select Cell

- (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?

ответ

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); 
} 
+0

Потрясающие спасибо много! Это был актерский состав, которого я отсутствовал. – mkral

+0

Хорошо, один быстрый вопрос. Если я 'performSegue' в' didSelect ... ', но я хочу' prepareSegue' с 'storyID', как я могу получить' index' из метода 'prepare'? – mkral

+0

Ничего, я решил отказаться от использования Segues и сделать все это программно. – mkral

Смежные вопросы