启动 View Controller 并移除 Tap 栏。 SWIFT
Start View Controller and remove Tap bar. SWIFT
我正在开发 swift 应用程序。我需要当我点击 table 中的一个项目时它会打开一个新视图。这很好并且可以工作,但是标签栏的底部按钮仍然存在。我该怎么做才能消失?
用于调用下一个屏幕的代码。我已经测试了一些不同的方法,但这是唯一有效的方法。我认为这不是这里的问题。
func irParaMarcacoes(nome:String){
let next:ViewMarcacaoController = storyboard?.instantiateViewControllerWithIdentifier("ViewMarcacaoController") as! ViewMarcacaoController
next.projNome = nome;
self.navigationController?.pushViewController(next, animated: true)
}
This is what I have, the first screen
This is what I want the tap bar to disappear
感谢您的关注。
*使用XCode 7.3
您正在从导航栏推送视图控制器
所以你推的控制器就是它的顶视图控制器
所以在视图中会出现方法
self.navigationController!.setNavigationBarHidden(true, animated: animated)
隐藏底栏
self.tabBarController?.tabBar.hidden = true
您可以隐藏导航栏。
在 ViewMarcacaoController
中写入此代码
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBarHidden = true
}
我找到了 Michael Campsall in here 提供的一个很好的解决方案。
解决方案主要包括:
func setTabBarVisible(visible:Bool, animated:Bool) {
//* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time
// bail if the current state matches the desired state
if (tabBarIsVisible() == visible) { return }
// get a frame calculation ready
let frame = self.tabBarController?.tabBar.frame
let height = frame?.size.height
let offsetY = (visible ? -height! : height)
// zero duration means no animation
let duration:NSTimeInterval = (animated ? 0.3 : 0.0)
// animate the tabBar
if frame != nil {
UIView.animateWithDuration(duration) {
self.tabBarController?.tabBar.frame = CGRectOffset(frame!, 0, offsetY!)
return
}
}
}
func tabBarIsVisible() ->Bool {
return self.tabBarController?.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame)
}
在您的第二个屏幕上启用 Hide Bottom bar on Push 故事板中的视图控制器,如下所示:
因此,当您按下 viewcontroller 时,它会隐藏底部的标签栏。当您返回到 firstViewController 时,将显示标签栏。无需为此编写代码。
希望对您有所帮助..
我正在开发 swift 应用程序。我需要当我点击 table 中的一个项目时它会打开一个新视图。这很好并且可以工作,但是标签栏的底部按钮仍然存在。我该怎么做才能消失?
用于调用下一个屏幕的代码。我已经测试了一些不同的方法,但这是唯一有效的方法。我认为这不是这里的问题。
func irParaMarcacoes(nome:String){
let next:ViewMarcacaoController = storyboard?.instantiateViewControllerWithIdentifier("ViewMarcacaoController") as! ViewMarcacaoController
next.projNome = nome;
self.navigationController?.pushViewController(next, animated: true)
}
This is what I have, the first screen
This is what I want the tap bar to disappear
感谢您的关注。
*使用XCode 7.3
您正在从导航栏推送视图控制器
所以你推的控制器就是它的顶视图控制器
所以在视图中会出现方法
self.navigationController!.setNavigationBarHidden(true, animated: animated)
隐藏底栏
self.tabBarController?.tabBar.hidden = true
您可以隐藏导航栏。
在 ViewMarcacaoController
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBarHidden = true
}
我找到了 Michael Campsall in here 提供的一个很好的解决方案。
解决方案主要包括:
func setTabBarVisible(visible:Bool, animated:Bool) {
//* This cannot be called before viewDidLayoutSubviews(), because the frame is not set before this time
// bail if the current state matches the desired state
if (tabBarIsVisible() == visible) { return }
// get a frame calculation ready
let frame = self.tabBarController?.tabBar.frame
let height = frame?.size.height
let offsetY = (visible ? -height! : height)
// zero duration means no animation
let duration:NSTimeInterval = (animated ? 0.3 : 0.0)
// animate the tabBar
if frame != nil {
UIView.animateWithDuration(duration) {
self.tabBarController?.tabBar.frame = CGRectOffset(frame!, 0, offsetY!)
return
}
}
}
func tabBarIsVisible() ->Bool {
return self.tabBarController?.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame)
}
在您的第二个屏幕上启用 Hide Bottom bar on Push 故事板中的视图控制器,如下所示:
因此,当您按下 viewcontroller 时,它会隐藏底部的标签栏。当您返回到 firstViewController 时,将显示标签栏。无需为此编写代码。
希望对您有所帮助..