iPhone how to change window
I'm new to iPhone development (except developing with cocos2d).
I want to create a simple application that have one window with a button. When i press the button i want some other window to be shown.
Where can i read how do such things?
Also i don't understand well what is 开发者_运维问答View, ViewController, Window. I've read the your first iOS app
example.
Look for tutorials on UINavigationController, like this one.
For the meaning of view and view controller you certainly want to read the apple references or in wikipedia. The topic there would be MVC Pattern. As to your concrete problem: There is usually only one window in iPhone apps so you certainly want to have a button on a view and if you push that button that view disappears and instead a new view is shown. You accomplish that by removing the view with the button from its superview ( have a look at the topic tree hierarchy ) and then add the view you want to bee shown as a subview to the main window . Bottom line is there is one main window and you put views onto it by it's addSubview method. And you remove views by calling their removeFromSuperview method
You should to read it again or google it until you'll understand it well.
view is the graphic output, while view controller is what "manage" the behavior of the view in every event.
your function to navigate -
(IBAction) ButtonClicked
{
static YourViewController *viewController=nil;
if(viewController==nil)
viewController=[[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
}
精彩评论