Hide one view and unhide another upon touching a button
I have been creating "if/then" apps for android and now my boss want me to do the same for his iPad. I just need to 开发者_StackOverflowfigure out how to code so that when the buttons are clicked, it hides the current view (text and button) and reveals the next set of text and buttons.
Make sure your two sets of text/buttons are in two UIViews (I will refer to these as 'viewOne' and 'viewTwo'), when you want to swap your views, use this code:
[viewOne setHidden:[viewTwo isHidden]];
[viewTwo setHidden:![viewTwo isHidden]];
It's not the most understandable way to do this, but it's one of the shortest. For something easier to read:
if ([viewOne isHidden]) {
[viewOne setHidden:NO];
[viewTwo setHidden:YES];
} else {
[viewOne setHidden:NO];
[viewTwo setHidden:YES];
}
Either will work, it just depends on how you like to write your code.
精彩评论