我在github上发现了这个名为FoldingTabBar.iOS的惊人TabBar,我已经导入了,我可以打电话和使用但是有这个初始化程序,我不知道如何在swift中使用,我真的希望有人可以帮助我,在示例项目中,他在AppDelegate.m中调用
示例中的Object-C:
YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) self.window.rootViewController;
当我尝试在AppDelegate中创建YALFoldingTabBarController时,我有以下选项:
我在Swift中尝试的内容:
YALFoldingTabBarController()
YALFoldingTabBarController(coder: NSCoder)
YALFoldingTabBarController(nib: String bunble:NSBundle)
(sorry this is coming from memory so my be slightly wrong, but they are the default initializers for UIViewController)
我试试
var controller = YALFoldingTabBarController() controller = self.window.rootViewController as! YALFoldingTabBarController 错误无法转换
var controller = YALFoldingTabBarController(self.window.rootViewController)
No such initializer
我是如何从原始的Object-C初始化器转到Swift的?
提前致谢
答案 0 :(得分:1)
如果在Interface Builder中将根视图控制器的类设置为YALFoldingTabBarController,则不需要显式初始化。
ObjC线的Swift等价
(+ 1 2)
是
YALFoldingTabBarController *tabBarController = (YALFoldingTabBarController *) self.window.rootViewController;