私のアプリケーションでは、10 個UIButton
の s と 5 個のテキスト値の配列があります。各値を 10 個のボタンに 2 回割り当てたいですか? ここに私のコード
NSString *name;
int value = rand() % ([texts count] -1) ;
for(UIView *view in self.view.subviews)
{
if([view isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)view;
if(button.tag == 1||button.tag == 2||button.tag == 3||button.tag == 4||button.tag == 5||button.tag == 6||button.tag == 7||button.tag == 8||button.tag == 9||button.tag == 10||button.tag == 11||button.tag == 12||button.tag == 13||button.tag == 14||button.tag == 15||button.tag == 16||button.tag == 17||button.tag == 18||button.tag == 19||button.tag == 20)
{
name=[NSString stringWithFormat:@"%@",[texts objectAtIndex:value]];
[button setTitle:name forState:UIControlStateNormal];
NSLog(@"current name :%@",name);
}
}
}
2つのボタンでタイトルのみに変更するのを手伝ってください