2014-09-13 32 views
0

因此,我一直在使用一本名为“IOS in Action”的书来进行编程,而且我遇到了一些我无法弄清楚如何解决的问题。这一点就是让照片应用程序中的照片使用viewController显示在我的“相册”应用程序中。这些问题是:Property'collectionView'and'photos'not found

  1. 地产“的CollectionView”上键入“IAPhotoCollectionViewCell *”
  2. 不兼容的指针类型从结果类型“UICollectionView”
  3. 住宅“照片函数返回“IAPhotoCollectionViewCell *”的对象未找到'找不到'IAPhotoCollectionViewCell *'类型的对象

我是编程方面的新手,请解释为什么会发生这些情况以及如何解决这些问题。这里是我的代码IAPhotoCollectionViewcell.m

#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 *[email protected]"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 
代码

,也为IAAlbumPhotosViewController.h

#import <UIKit/UIKit.h> 
#import <AssetsLibrary/AssetsLibrary.h> 

@interface IAAlbumPhotosViewController : UICollectionViewController 
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView; 
@property (nonatomic, strong) ALAssetsGroup *album; 
@property (nonatomic, strong) NSMutableArray *photos; 

@end 

谢谢!

所以我已经尝试使用:

IAPhotoCollectionViewCell *cell = (IAPhotoCollectionViewCell*)[self.collectionView  dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; 

但我得到一个“财产‘的CollectionView’在类型的对象没有找到‘IAPhotoCollectionViewCell *’我会尝试添加属性‘的CollectionView’所以,我发现我的问题是,我没有为“的CollectionView”一个@property部分和一个错误就走开了。

+0

#1,'collectionView'是'IAAlbumPhotosViewController'而不是'IAPhotoCollectionViewCell'的属性。但是我们无法看到你想要使用该属性的位置。 #2,使用演员。 #3,与#1相同,但用于“照片”。看起来好像你在混淆你的界面。但是我无法在您发布的代码中看到这一点。 – Gutblender 2014-09-13 18:15:31

+0

对不起,新的,但请给我一个演员的例子 – 2014-09-13 21:08:46

+0

'IAPhotoCollectionViewCell * cell =(IAPhotoCollectionViewCell *)[self.collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];' – Gutblender 2014-09-13 21:12:23

回答

0

添加下面一行在我IAPhotoCollectionViewCell.h文件解决了这个问题

@property (nonatomic, retain) UICollectionView *collectionView