【发布时间】:2012-05-28 15:28:53
【问题描述】:
在为按钮设置图像时,我使用stringWithFormat:,如下所示:
[buttonImage setImage:[ImgUtil image:[NSString stringWithFormat:@"myImage_%d.png", selectNum + 1 ]] ];
我想检查那个字符串。我想也许我可以从按钮中取回名字:
if (buttonImage.image == [UIImage imageNamed:@"myImage_2.png"]) {
NSLog(@"the name of the buttonImage is %@", buttonImage.image);
}
但这不起作用。我怎么看那个字符串?
【问题讨论】:
-
@EvanMulawski:我不认为它是重复的。
-
@nhahtdh:是的。他想得到
UIImage对象所代表的图像的名称。 -
@EvanMulawski:问题可能相同,但目的和设置不同。
-
@nhahtdh:题名一样,题本身一样,最终结果一样。因此,这是同一个问题。
标签: objective-c cocoa-touch nsstring