画像を変更するためにこれを行っています。ここでは、UIButton
すべての「スイッチ」はIBOutlets
UIButton
-(IBAction)userselect:(id)sender
{
UIButton *btnTagcatcher =(UIButton * )sender;
if(btnTagcatcher.tag == 1)
{
if(btnimgflag1 == 0)
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"check-box-withtick-1n1"
ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
[switch1 setImage:image forState:UIControlStateNormal];
NSString* path1 = [[NSBundle mainBundle] pathForResource:@"check-box-withouttickn1"
ofType:@"png"];
UIImage *image1 = [[UIImage alloc] initWithContentsOfFile:path1];
[switch2 setImage:image1 forState:UIControlStateNormal];
[switch3 setImage:image1 forState:UIControlStateNormal];
[switch4 setImage:image1 forState:UIControlStateNormal];
btnimgflag2 = 0;
btnimgflag3 = 0;
btnimgflag4 = 0;
btnimgflag1 = 1;
}
else if(btnimgflag1 == 1)
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"check-box-withouttickn1"
ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
//[switch1 setImage: image];
[switch1 setImage:image forState:UIControlStateNormal];
btnimgflag1 = 0;
}
しかし、場合によっては(通常は最初に押されたとき)、タップしてもボタンの画像が変化しません。
ここで何が起こっているのかわかりません。これで私を案内してください、事前に感謝します。
よろしくサード。