Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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[\uu NSCFConstantString\u isResizable]:发送到实例的未识别选择器_Ios_String_Multithreading_Sigabrt - Fatal编程技术网

Ios CollectionView[\uu NSCFConstantString\u isResizable]:发送到实例的未识别选择器

Ios CollectionView[\uu NSCFConstantString\u isResizable]:发送到实例的未识别选择器,ios,string,multithreading,sigabrt,Ios,String,Multithreading,Sigabrt,当我运行我的应用程序时,我发现一个信号SIGABRT线程。以下是错误消息: [\uu NSCFConstantString\u IsResizeable]:发送到实例0x5c20的未识别选择器 问题来自于 [[self myCollectionView]setDataSource:self]; 因为当我评论它的时候它就消失了 据我所知,myCollectionView数据源和self的类型不同。这就是我犯错误的原因 谢谢你的帮助 皮埃尔 卡尔维控制器 #import <UIKit/UIKi

当我运行我的应用程序时,我发现一个信号SIGABRT线程。以下是错误消息: [\uu NSCFConstantString\u IsResizeable]:发送到实例0x5c20的未识别选择器

问题来自于 [[self myCollectionView]setDataSource:self]; 因为当我评论它的时候它就消失了

据我所知,myCollectionView数据源和self的类型不同。这就是我犯错误的原因

谢谢你的帮助

皮埃尔

卡尔维控制器

#import <UIKit/UIKit.h>

@interface CalViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;

@end

尝试替换
[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]]带有

NSString *imageName = [arrayOfImages objectAtIndex:indexPath.item];
[cell.myImage setImage:[UIImage imageNamed:imageName];

问题是,现在您正试图将
NSString
分配给应该是
UIImage
的对象,请尝试替换
[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]带有

NSString *imageName = [arrayOfImages objectAtIndex:indexPath.item];
[cell.myImage setImage:[UIImage imageNamed:imageName];

问题是,现在您正试图将一个
NSString
分配给应该是
UIImage
的对象,您的
arrayOfImages
是一个图像名称(字符串)数组,因此
setImage
无法使用该数组。而不是:

[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]];
您可能打算:

[[cell myImage]setImage:[UIImage imageNamed:[arrayOfImages objectAtIndex:indexPath.item]]];
或者,相当于:

cell.myImage.image = [UIImage imageNamed:arrayOfImages[indexPath.item]];
您甚至可能希望将
arrayOfImages
重命名为
arrayOfImageNames
(或只是
imageNames
或其他)以消除这种可能的混淆源


(顺便说一句,最好不要将实际图像放入数组中。我们应该始终根据数组中的图像名称在
cellForItemAtIndexPath
中创建图像对象。)

您的
arrayOfImages
是一个图像名称(字符串)数组,因此
setImage
无法使用该数组。而不是:

[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]];
您可能打算:

[[cell myImage]setImage:[UIImage imageNamed:[arrayOfImages objectAtIndex:indexPath.item]]];
或者,相当于:

cell.myImage.image = [UIImage imageNamed:arrayOfImages[indexPath.item]];
您甚至可能希望将
arrayOfImages
重命名为
arrayOfImageNames
(或只是
imageNames
或其他)以消除这种可能的混淆源


(顺便说一句,最好不要将实际图像放入数组中。我们应该始终根据数组中的图像名称在
cellForItemAtIndexPath
中创建图像对象。)

谢谢Rob。现在可以了!谢谢你,罗布。现在可以了!