私application
はクイズに関連するようなものです,私のビューでは1つの画像ビューと4つUIbuttons
があります,最初に画像をロードしてimageview
4つのボタンタイトルをシャッフル方法で割り当てる必要があります,ボタンの1つは現在の画像名にする必要があります,ユーザーがクリックした場合ボタン 次のボタンのタイトルと新しいセットを表示したいimage
-(IBAction)answersetting:(id)sender
{
int i=0;
UIButton *mybutton = (UIButton *)sender;
[mybutton addTarget:self action:@selector(submitGuess:)
forControlEvents:UIControlEventValueChanged];
if(mybutton.tag == 1||mybutton.tag == 2||mybutton.tag == 3||mybutton.tag == 4)
{
for(int loop = 0; loop<4;loop++)
{
animage.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg",[imageary objectAtIndex:i]]];
name=[self convertToDisplayName:[imageary objectAtIndex:i]];
[mybutton setTitle:name forState:UIControlStateNormal];
NSLog(@"current image name :%@",name);
if ([mybutton.titleLabel.text isEqualToString:[imageary objectAtIndex:i]])
{
//titles equal
[self alertshow];
i++;
}
UIView *newView = [self.view viewWithTag:i];
if([newView isKindOfClass:[UIButton class]])
{
UIButton *newButton = (UIButton *)newView;
[newButton setTitle:name forState:UIControlStateNormal];
}
}
}
}
これは、上記で説明したことを実行できません。コードにどのような変更を加える必要がありますか?この問題の解決を手伝ってください