视图界面切换

阅读更多
首先在在AppDelegate.m里的:(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中加入 ViewController *viewcontroller=[ViewController new];
    UINavigationController *uinavigationcontroller=[[UINavigationController alloc]initWithRootViewController:viewcontroller];//先将ViewController添加到navigation上;
    self.window.rootViewController=uinavigationcontroller;//navigation加在window上


接下来页面之间的跳转通过(比如a➡️b):在a类事件函数中添加:[self.navigationController pushViewController:b animated:true];可以实现a跳到b。

如果想回到上一级一面可以写:self.navigationController popViewControllerAnimated:YES];
}
如果想跳回首界面:self.navigationController popRootViewControllerAnimated:YES];
}

你可能感兴趣的:(iOS,视图切换,Objective-C,Cocoa)