Ios 财产';collectionView';和';照片';找不到
因此,我一直在使用一本名为《IOS在运行》的书进行编程,我遇到了一些无法解决的问题。这一点是让照片应用程序中已经存在的照片使用viewController显示在我的相册应用程序中。问题是:Ios 财产';collectionView';和';照片';找不到,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,因此,我一直在使用一本名为《IOS在运行》的书进行编程,我遇到了一些无法解决的问题。这一点是让照片应用程序中已经存在的照片使用viewController显示在我的相册应用程序中。问题是: 在类型为“IAPhotoCollectionViewCell*”的对象上找不到属性“collectionView” 从结果类型为“UICollectionView”的函数返回“IAPhotoCollectionViewCell*”的指针类型不兼容 在类型为“IAPhotoCollectionViewCell*
#import "IAPhotoCollectionViewCell.h"
#import "IAAlbumPhotosViewController.h"
@implementation IAPhotoCollectionViewCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
-(UICollectionView*)collectionView:(UICollectionView*)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"photoCell";
IAPhotoCollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
ALAsset *asset = self.photos[indexPath.row];
cell.imageView.image=[UIImage imageWithCGImage:asset.thumbnail];
return cell;
}
@end
这是我的IAPhotoCollectionViewCell.h代码
#import <UIKit/UIKit.h>
@interface IAPhotoCollectionViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
但是我有一个在类型为“IapoticollectionViewCell*”的对象上找不到属性“collectionView”,我将尝试添加属性“collectionView”。因此,我发现我的问题是,我没有为“collectionView”设置@property部分,错误消失了 在我的IAPhotoCollectionViewCell.h文件中添加以下行解决了问题
@property (nonatomic, retain) UICollectionView *collectionView
#1,
collectionView
是IAAlbumPhotosViewController
上的属性,而不是IAPhotoCollectionViewCell
。但我们看不到你想在哪里使用这些财产#2、使用石膏#3,与#1相同,但用于照片
。看起来好像你混淆了你的界面。但是我在你发布的代码中看不到这一点。很抱歉是新的,但是你能给我一个castIAPhotoCollectionViewCell*cell=(IAPhotoCollectionViewCell*)[self.collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]的示例吗我试过了,但没用。还有其他想法吗?你为什么不在帖子里这么说?做一个编辑,显示这一点,以及出错的地方。告诉我“它不起作用”告诉我的很少。
IAPhotoCollectionViewCell *cell = (IAPhotoCollectionViewCell*)[self.collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
@property (nonatomic, retain) UICollectionView *collectionView