Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 财产';collectionView';和';照片';找不到_Ios_Objective C_Uicollectionview - Fatal编程技术网

Ios 财产';collectionView';和';照片';找不到

Ios 财产';collectionView';和';照片';找不到,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,因此,我一直在使用一本名为《IOS在运行》的书进行编程,我遇到了一些无法解决的问题。这一点是让照片应用程序中已经存在的照片使用viewController显示在我的相册应用程序中。问题是: 在类型为“IAPhotoCollectionViewCell*”的对象上找不到属性“collectionView” 从结果类型为“UICollectionView”的函数返回“IAPhotoCollectionViewCell*”的指针类型不兼容 在类型为“IAPhotoCollectionViewCell*

因此,我一直在使用一本名为《IOS在运行》的书进行编程,我遇到了一些无法解决的问题。这一点是让照片应用程序中已经存在的照片使用viewController显示在我的相册应用程序中。问题是:

  • 在类型为“IAPhotoCollectionViewCell*”的对象上找不到属性“collectionView”
  • 从结果类型为“UICollectionView”的函数返回“IAPhotoCollectionViewCell*”的指针类型不兼容
  • 在类型为“IAPhotoCollectionViewCell*”的对象上找不到属性“photos”
  • 我是一个编程新手,所以请解释为什么会发生这些情况以及如何修复它们。这是我的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 *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相同,但用于
    照片
    。看起来好像你混淆了你的界面。但是我在你发布的代码中看不到这一点。很抱歉是新的,但是你能给我一个cast
    IAPhotoCollectionViewCell*cell=(IAPhotoCollectionViewCell*)[self.collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]的示例吗IAPhotoCollectionViewCell *cell = (IAPhotoCollectionViewCell*)[self.collectionView     dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    
    @property (nonatomic, retain) UICollectionView *collectionView