0

I've currently got a method that allows the user to press on a button and it sets its state to isSelected = YES, the title of this button is then appended to an NSString. If the user then presses the button again the title is removed from the string and the button isSelected = NO.

Any button connected to this method will succesfully add and remove text from said string. This is being done in the method via:

UIButton *tempbutton = (UIButton *)sender;

I then get the title from this tempButton and append to a string. Now i have many buttons the user can press on in this menu but what i'd like to be able to do is loop through all the buttons in the view and set their isSelected = NO. I'd like to be able to do this without having to setup property / synthesize for every button.

Is this possible, i can post the code i have tried shortly, but if there is a standard way of doing this it would be great.

4

1 に答える 1

0

わかりました。ストーリーボードの各UIButtonを単一のアウトレットコレクション(新しい参照アウトレットコレクション)に接続し、配列をループしてボタンの選択状態を設定しました。

// remove button highlights
for (int i =0; i<[quickNotesCollection count]; i++){
[[quickNotesCollection objectAtIndex:i]setSelected:NO];
}

これが同様の問題を抱えている他の人に役立つことを願っています。2回目は自分の質問に答えました:)

于 2012-11-29T15:38:26.257 に答える