gpt4 book ai didi

iphone - 无法设置图片

转载 作者:行者123 更新时间:2023-12-01 18:03:24 26 4
gpt4 key购买 nike

Noob Alert,

我正在尝试更改UIImageView中的图像。

popCard是指向UIImageView的IBOutlet-在IB中为空白。

有5个可能的图像(Graphic0,Graphic1等)

由于某种原因,它一直显示Graphic1。

我感觉到我缺少一些简单的东西。你能帮忙吗?

这是我正在使用的:

getCard=0;
NSLog(@"begin showCard = %i",getCard);
FlowCoverAppDelegate *mainDelegate = (FlowCoverAppDelegate *)[[UIApplication sharedApplication]delegate];
getCard = mainDelegate.showCard;
NSLog(@"showCard = %i",getCard);

if (getCard = 0) {
[popCard setImage:[UIImage imageNamed:@"Graphic0.jpg"]];
popCard.contentMode = UIViewContentModeScaleAspectFit;
return;
}

干杯
保罗

最佳答案

您的代码存在以下问题:

您正在getCard表达式中将0分配给if,将其更改为==

另外,如果getCard不是对象的属性,则需要将其声明为int getCard = 0;
您应该做什么:

不用编写5条if语句,只需编写这一行:

[popCard setImage:[UIImage imageNamed: [ NSString stringWithFormat: @"Graphic%d.jpg", getCard ] ] ];

关于iphone - 无法设置图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2100861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com