2011-03-28 95 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; } ... ..