2011-03-28 53 views
0

我有一個帶有四個按鈕的主視圖,每次單擊一個按鈕時都會添加一個子視圖。但是當我點擊按鈕,子視圖出現時,我無法按下任何其他按鈕。有沒有人有什麼建議? Here's一個按鈕被點擊時的代碼:使用按鈕切換視圖

newView = [[UIView alloc] initWithFrame:CGRectMake(25,25,50,20)]; 
[newView addSubview: testArena.view]; 
[newView setFrame:CGRectMake(0.0f, 480.0f, 320.0f, 480.0f)]; 
[UIView beginAnimations:@"animateArenaView" context:nil]; 
[UIView setAnimationDuration:0.4]; 
[newView setFrame:CGRectMake(0.0f, 20.0f, 320.0f, 460.0f)]; 
[UIView commitAnimations]; 
[newView setUserInteractionEnabled:YES]; 
[self.view addSubview: newView]; 

凡NewView的是一個UIView,和testArena.view是類I'm讓我想從顯示的視圖。

回答

1

聽起來像newView可能是隱藏/停止按鈕被按下?嘗試將它發送到後面,所以它不能覆蓋按鈕:

[self.view sendSubviewToBack:newView]; 
+0

呀,that's我以爲那就是,NewView的覆蓋按鈕莫名其妙。我試着把[self.view sendSubviewToBack:newView];在loadView和我的操作方法。仍然沒有工作。 – Magnus 2011-03-28 12:03:40

+0

沒關係,我明白了,非常感謝喬丹! :-) – Magnus 2011-03-28 12:09:35

0

,而你在點擊一個按鈕裏面,你可以禁用所有其他的按鈕..

如果(按鈕1){ BUTTON2用戶交互啓用=無; button3 userinteraction enable = no; button4 userinteraction enable = no; } if(button2){button1} userinteraction enable = no; button3 userinteraction enable = no; button4 userinteraction enable = no; } ... ..