我有这两种方法:
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 :(得分:4)
删除微调器后,可以使用延迟显示后退按钮。像0.2秒或根据要求
func hideSpinner()
{
self.navigationItem.leftBarButtonItem = nil
dispatch_after(1, dispatch_get_main_queue()) { () -> Void in
self.navigationItem.hidesBackButton = false
};
}