如何在故事板中加载标签栏控制器之前初始化自定义启动画面?
How to initialise a custom splash screen before loading tab bar controller in storyboard?
我有一个应用程序,其中有一个自定义启动视图控制器,然后出现了标签栏控制器。目前我已经将标签栏控制器设置为初始视图控制器。但我希望启动视图控制器首先出现,然后是选项卡栏控制器。知道怎么做吗?
在tabcontroller的viewWillAppear
中push的时候可以播放5秒的视频。
您还可以在 tabcontroller 之间再添加一个控制器,这样您的初始控制器就是 rootviewcontroller。
您首先需要将启动视图控制器设置为 rootViewController,然后将 modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
设置为 rootViewController 并显示您的 tabviewcontroller 或更改 rootViewController
使用 presentViewController 代替 PushView Controller
试试这个代码
override func viewDidLoad() {
super.viewDidLoad()
_ = NSTimer.scheduledTimerWithTimeInterval(2.1, target: self, selector: #selector(Splash.someSelector), userInfo: nil, repeats: false)
// Do any additional setup after loading the view.
}
func someSelector() {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : TabBarCotroller = storyboard.instantiateViewControllerWithIdentifier("TabBarCotroller") as! TabBarCotroller
let navigationController = UINavigationController(rootViewController: vc)
self.present(navigationController, animated: true, completion: nil)
}
是的,你可以用这种方式做这件事,
首先在情节提要中制作自定义 class 视图控制器作为初始视图控制器。然后将标签栏控制器推送到当前导航控制器。
let tabBarVC = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController
tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBarVC, animated: true)
试试这个可能对你有帮助。
@Amelia frensheo 类似的东西:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
appDelegate.window.rootViewController = [[SplashViewCtr alloc] init];
appDelegate.window.rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[appDelegate.window makeKeyAndVisible];
UITabBarController *rootViewCtrl = [[UITabBarController alloc] init];
第一种方式
[appDelegate.window.rootViewController presentViewController:rootViewCtrl animated:YES completion:nil];
第二种方式
[UIView transitionFromView:window.rootViewController.view toView:rootViewCtrl.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
appDelegate.window.rootViewController = rootViewCtrl.view;
}];
首先在故事板中将自定义 class 视图控制器设为 Initial view controller
。然后将 tabbar
控制器推到当前 navigation controller
.
let tabBar = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBar, animated: true)
我有一个应用程序,其中有一个自定义启动视图控制器,然后出现了标签栏控制器。目前我已经将标签栏控制器设置为初始视图控制器。但我希望启动视图控制器首先出现,然后是选项卡栏控制器。知道怎么做吗?
在tabcontroller的viewWillAppear
中push的时候可以播放5秒的视频。
您还可以在 tabcontroller 之间再添加一个控制器,这样您的初始控制器就是 rootviewcontroller。
您首先需要将启动视图控制器设置为 rootViewController,然后将 modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
设置为 rootViewController 并显示您的 tabviewcontroller 或更改 rootViewController
使用 presentViewController 代替 PushView Controller 试试这个代码
override func viewDidLoad() {
super.viewDidLoad()
_ = NSTimer.scheduledTimerWithTimeInterval(2.1, target: self, selector: #selector(Splash.someSelector), userInfo: nil, repeats: false)
// Do any additional setup after loading the view.
}
func someSelector() {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc : TabBarCotroller = storyboard.instantiateViewControllerWithIdentifier("TabBarCotroller") as! TabBarCotroller
let navigationController = UINavigationController(rootViewController: vc)
self.present(navigationController, animated: true, completion: nil)
}
是的,你可以用这种方式做这件事,
首先在情节提要中制作自定义 class 视图控制器作为初始视图控制器。然后将标签栏控制器推送到当前导航控制器。
let tabBarVC = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController
tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBarVC, animated: true)
试试这个可能对你有帮助。
@Amelia frensheo 类似的东西:
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
appDelegate.window.rootViewController = [[SplashViewCtr alloc] init];
appDelegate.window.rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[appDelegate.window makeKeyAndVisible];
UITabBarController *rootViewCtrl = [[UITabBarController alloc] init];
第一种方式
[appDelegate.window.rootViewController presentViewController:rootViewCtrl animated:YES completion:nil];
第二种方式
[UIView transitionFromView:window.rootViewController.view toView:rootViewCtrl.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
appDelegate.window.rootViewController = rootViewCtrl.view;
}];
首先在故事板中将自定义 class 视图控制器设为 Initial view controller
。然后将 tabbar
控制器推到当前 navigation controller
.
let tabBar = self.storyboard!.instantiateViewControllerWithIdentifier("tabBarViewController") as! UITabBarController tabBarVC.selectedIndex = 0
self.navigationController?.pushViewController(tabBar, animated: true)