2013-07-25 3 views
0

나는이 응용 프로그램을 작성 중이며이 오류가 발생합니다. 내가 어떻게 고칠 지 확신 할 수 없다. 고맙습니다.헤더 파일에 뭔가를 추가해야합니까?

오류가 선언되지 않은 식별자 'collectionView'

헤더 파일을 가져오고있다.

헤더 : 오류가

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath*)indexPath 
{ 
    if(shareEnabled){ 
     //determine the selected items by using the indexPath 
     NSString *selectedPhotos = [tagImages[indexPath.section] objectAtIndex:indexPath]; 

     //add selected image into the array 
     [selectedPhotos addObject:selectedPhotos]; 
    } 
} 

덕분에 많이들

나도 같은하는 .m 파일에 collectionView 여러 번 사용을 발생

#import <UIKit/UIKit.h> 
NSMutableData *content; 

@interface AMCollectionViewController : UICollectionViewController 


@property (weak, nonatomic) IBOutlet UIBarButtonItem *tagButton; 

- (IBAction)tagButtonTouched:(id)sender; 

@end 

구현

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 

    return 50; 

} 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 
     static NSString *identifier [email protected]"Cell"; 

     AMCollectionViewCell *cell = (AMCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; 

     int imageNumber = indexPath.row % 10; 



     cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"imageicon%d.jpg",imageNumber]]; 
     cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageBorder.jpg"]]; 


     return cell; 
    } 
+1

무엇이 오류입니까? – rmaddy

+0

헤더 (.h)를 구현 파일 (.m)에'# 가져 오기 '하시겠습니까? –

+0

'편집'을 사용하여 질문에 오류를 추가하십시오. – Popeye

답변

0
내가 그 오류 모르는

하지만

  1. 이 라인에 indexPath에 두 번째 참조가 잘 될 수 없습니다

    NSString *selectedPhotos = [tagImages[indexPath.section] objectAtIndex:indexPath]; 
    

    objectAtIndex 매개 변수는 필요 정수. (objectAtIndex를 사용하거나 [] 구문을 사용하지만 사용하여 두 조금 호기심 중 하나)

    NSString *selectedPhotos = [tagImages[indexPath.section] objectAtIndex:indexPath.item]; 
    

    하거나, 일관성을 : 당신은 아마 의미

    NSString *selectedPhotos = tagImages[indexPath.section][indexPath.item]; 
    
  2. 당신은 표시하지 않은 tagImages의 선언 또는 초기화는 아니지만 문자열 배열 배열 tagImages이라고 가정합니다. 그렇다면 위의 수정으로 수정해야합니다. 그렇지 않은 경우 tabImages이 채워지거나 구조화 된 방법을 알려주십시오.

  3. selectedPhotosNSString 인 경우, addObject 방법의 사용은 가능하지 않습니다. addObject 메서드는 NSMutableArray 메서드이며 NSString 메서드는 아닙니다.

+0

당신이 제안한 모든 변경 사항을 구현했고, 유일한 오류는 여전히 선언되지 않은 식별자 'collectionView'입니다. – user2469203

+0

@ user2469203 어떤 코드 줄에서 오류가 표시됩니까? 아마도 현재 코드로 질문을 업데이트 할 수있을뿐만 아니라 오류를 생성하는 코드 행을 명확하게 표시 할 수 있습니다. – Rob