我有6個按鈕放置在一個視圖,並試圖相應地改變的backgroundColor:迭代通過按鈕sender.superview
- (IBAction)btnPressed:(UIButton *)sender {
for(UIButton *btn in sender.superview){
[btn setBackgroundColor:[UIColor whiteColor]];
}
[sender setBackgroundColor:[UIColor blackColor]];
}
以下錯誤消息: [UIView的countByEnumeratingWithState:對象:計數:]:無法識別的選擇發送到實例0x174191d30 2015-07-20 17:12:00.853 Raymio [20370:2209236] ***由於未捕獲異常'NSInvalidArgumentException',原因:' - [UIView countByEnumeratingWithState:objects:count:]:無法識別的選擇器已發送到實例0x174191d30'
我得到一個編譯器警告警報這可能會發生,但我是不是正確得到發件人這樣的superview?
編輯:也許我誤解了某事。我有一個視圖控制器(主視圖obv)。在那個vc中,我有很多意見,包括一個視圖,我有6個按鈕。我想在那個特定視圖只有6個按鈕,所以我試圖讓發送方的上海華,以爲我得到了我用來放置6個按鈕在視圖中。
嗯,喲你無法遍歷單個視圖? –
@davidcao我不知道這是否意味着修辭或什麼。無論如何,我在一個視圖中迭代x個按鈕的數量? – DevilInDisguise