Using buttons to switch views
I have a main view with four buttons, each time a button is clicked a subview is added. But when I click the button, and the subview comes up, I can´t pressed any of the other buttons. Does anyone have any suggestions? Here´s the code when a buttons is clicked:
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];
Where newView is a UIView, and testArena.view is the class I´m getting the view I want displayed from.
Sounds like newView might be hiding/stopping the buttons from being pressed? Try sending it to the back, so it can't cover the buttons:
[self.view sendSubviewToBack:newView];
while you click on one button inside that you can disable all other buttons..
if(button1){ button2 userinteraction enable = no; button3 userinteraction enable = no; button4 userinteraction enable = no; } if(button2){ button1 userinteraction enable = no; button3 userinteraction enable = no; button4 userinteraction enable = no; } ... ..
精彩评论