我如何让这段代码在 SplashView
NIB 中呈现动画而不只是让它出现(例如 UIModalTransitionStyleFlipHorizontal
样式)?我正在使用 UITabBarController
类型的项目。
- (IBAction)showSplash:(id)sender {
// Hide toolbar
self.tabBarController.tabBar.hidden = YES;
// Splash
[[NSBundle mainBundle] loadNibNamed: @"SplashView" owner: self options: nil];
[self.view addSubview: splashView];
[window makeKeyAndVisible];
}
最佳答案
用这一小段代码很难说出您的上下文。基本上,如果你想在你的 -(IBAction)showSplash 方法中模态地推送一个 viewController(顺便说一句,如果你不使用它,你不需要发送发送者),我会使用一些类似的代码:
SplashViewController *svc = [[SplashViewController alloc] init]; (assuming nib is same name)
self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:svc animated:YES];
[svc release];
然后在您的 SplashViewController 中您将有一个 IBAction 调用:
[self dismissModalViewController animated:YES];
当您呈现 modalViewController 时,您实际上不必隐藏 tabBar。它不会在那里。 modalViewController 的想法是它阻止所有用户与应用程序的交互,除了模态视图,直到它被处理。
希望这对您有所帮助。
关于objective-c - 动画加载 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5387103/