我有两种方法:
func showSpinner()
{
let spinner = UIActivityIndicatorView(activityIndicatorStyle: .White)
spinner.startAnimating()
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: spinner)
self.navigationItem.hidesBackButton = true
}
func hideSpinner()
{
self.navigationItem.leftBarButtonItem = nil
self.navigationItem.hidesBackButton = false
}
在
viewDidLoad
中,我叫showSpinner
,然后在加载数据后,我叫hideSpinner
。但是backButton经常跳到hideSpinner
上。如何解决? 最佳答案
移除微调器后,可以使用延迟显示后退按钮。大约0.2秒或根据要求
func hideSpinner()
{
self.navigationItem.leftBarButtonItem = nil
dispatch_after(1, dispatch_get_main_queue()) { () -> Void in
self.navigationItem.hidesBackButton = false
};
}
关于ios - 导航栏中的隐藏和显示后退按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30303790/