Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Objective c 试图在我的老虎机iPhone应用程序中加载图像,但出现错误(NSInvalidArgumentException)_Objective C_Xcode_Uiimage - Fatal编程技术网

Objective c 试图在我的老虎机iPhone应用程序中加载图像,但出现错误(NSInvalidArgumentException)

Objective c 试图在我的老虎机iPhone应用程序中加载图像,但出现错误(NSInvalidArgumentException),objective-c,xcode,uiimage,Objective C,Xcode,Uiimage,我对hole Xcode/objective-c是个新手,所以如果能以我能理解你的方式回答我的问题,那就太好了:) 我的问题是:我试图创建一个带有选择器和按钮的老虎机(当然是用来旋转轮子的),所以我实现了5个图像(苹果、皇冠、樱桃、柠檬、七、香蕉),但在启动应用程序时,我出现了以下错误: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIImage initWithImage:]:无法识别的选择器已发送到实例0x4b649b0” 我的代码如下

我对hole Xcode/objective-c是个新手,所以如果能以我能理解你的方式回答我的问题,那就太好了:) 我的问题是:我试图创建一个带有选择器和按钮的老虎机(当然是用来旋转轮子的),所以我实现了5个图像(苹果、皇冠、樱桃、柠檬、七、香蕉),但在启动应用程序时,我出现了以下错误:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIImage initWithImage:]:无法识别的选择器已发送到实例0x4b649b0”

我的代码如下所示:

- (void)viewDidLoad {
UIImage *apple = [UIImage imageNamed:@"apple.png"];
UIImage *banana = [UIImage imageNamed:@"banana.png"];    
UIImage *cherry = [UIImage imageNamed:@"cherry.png"];
UIImage *crown = [UIImage imageNamed:@"crown.png"];
UIImage *lemon = [UIImage imageNamed:@"lemon.png"];
UIImage *seven = [UIImage imageNamed:@"seven.png"];    

for (int i = 1; i <= 5; i++) {
    UIImageView *appleView = [[UIImage alloc] initWithImage:apple];
    UIImageView *bananaView = [[UIImage alloc] initWithImage:banana];    
    UIImageView *cherryView = [[UIImage alloc] initWithImage:cherry];    
    UIImageView *crownView = [[UIImage alloc] initWithImage:crown];   
    UIImageView *lemonView = [[UIImage alloc] initWithImage:lemon];   
    UIImageView *sevenView = [[UIImage alloc] initWithImage:seven];    

    NSArray *imageViewArray = [[NSArray alloc] initWithObjects:appleView, bananaView, cherryView, crownView, lemonView, sevenView, nil];

    NSString *fieldName = [[NSString alloc] initWithFormat:@"column%d", i];
    [self setValue: imageViewArray forKey:fieldName];
    [fieldName release];
    [imageViewArray release];
    [appleView release];
    [bananaView release];
    [cherryView release];
    [crownView release];
    [lemonView release];
    [sevenView release];
-(void)viewDidLoad{
UIImage*apple=[UIImage ImageName:@“apple.png”];
UIImage*banana=[UIImage ImageName:@“banana.png”];
UIImage*cherry=[UIImage ImageName:@“cherry.png”];
UIImage*crown=[UIImage ImageName:@“crown.png”];
UIImage*lemon=[UIImage ImageName:@“lemon.png”];
UIImage*seven=[UIImage ImageName:@“seven.png”];

对于(inti=1;i您需要使用

[[UIImageView alloc] initWithImage: ...]
不是

[[UIImage alloc] initWithImage: ...]