【发布时间】:2013-07-25 16:00:51
【问题描述】:
我正在编写一个应用程序并收到此错误。不知道我将如何修复它。谢谢。
错误是未声明的标识符“collectionView”
并且正在导入头文件。
标题:
#import <UIKit/UIKit.h>
NSMutableData *content;
@interface AMCollectionViewController : UICollectionViewController
@property (weak, nonatomic) IBOutlet UIBarButtonItem *tagButton;
- (IBAction)tagButtonTouched:(id)sender;
@end
发生错误时的实现
- (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
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 50;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier =@"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;
}
【问题讨论】:
-
您是否在实现 (.m) 文件中
#importing 您的标头 (.h)? -
请使用
edit在问题中添加错误 -
您有一个名为
collectionView的东西,它尚未在任何地方声明。你觉得你如何声明和初始化collectionView?
标签: objective-c compiler-errors uicollectionview