我想在每次出现floatingViewController时隐藏一个FabButton,并在关闭视图时再次显示它。
我尝试用
隐藏FabButton本身class FileObject
{
var path:String
init(_ path:String)
{ self.path = path }
}
var files:[FileObject] =
[
FileObject("./b/c.ext"),
FileObject("./f.ext"),
FileObject("./g.ext"),
FileObject("./a/a.ext"),
FileObject("./b/b.ext"),
FileObject("./b/d/d.ext"),
FileObject("./c/e.ext")
]
files = files.map({ ($0, $0.path.rangeOfString("/", options: .BackwardsSearch)!) })
.map({ ($0, $0.path.stringByReplacingCharactersInRange($1, withString: "/ ")) })
.map({ ($0, $1.lowercaseString) })
.sort({ $0.1 < $1.1 })
.map({ $0.0 })
files.forEach({ print($0.path) })
// prints:
//
// ./f.ext
// ./g.ext
// ./a/a.ext
// ./b/b.ext
// ./b/c.ext
// ./b/d/d.ext
// ./c/e.ext
// Benchmark for 8000 gives 0.134 sec.
但是当我关闭floatingViewController时没有回调函数,所以我没有办法取消隐藏它。
我也尝试手动设置zPosition,但按钮不受影响
有更好的方法吗?
答案 0 :(得分:0)
NavigationBarViewController具有用于检测floatingViewController状态的委托方法。设置委托对象
navigationBarViewController?.delegate = self
然后尝试委托方法:
extension AppNavigationBarViewController: NavigationBarViewControllerDelegate {
/// Delegation method that executes when the floatingViewController will open.
func navigationBarViewControllerWillOpenFloatingViewController(navigationBarViewController: NavigationBarViewController) {
print("Will Open")
}
/// Delegation method that executes when the floatingViewController will close.
func navigationBarViewControllerWillCloseFloatingViewController(navigationBarViewController: NavigationBarViewController) {
print("Will Close")
}
/// Delegation method that executes when the floatingViewController did open.
func navigationBarViewControllerDidOpenFloatingViewController(navigationBarViewController: NavigationBarViewController) {
print("Did Open")
}
/// Delegation method that executes when the floatingViewController did close.
func navigationBarViewControllerDidCloseFloatingViewController(navigationBarViewController: NavigationBarViewController) {
print("Did Close")
}
}
您应该能够使用这些方法来达到预期的效果。
答案 1 :(得分:0)
将此方法添加到FloatingViewController类
override func viewWillDisappear(animated: Bool) {
let vc = ...assign to the viewcontroller that holds tour menu button
vc.menuButton.hidden = false
}