我在tvOS平台上有转换错误:当我按下"输入"遥控器上的按钮两次我有双转换到下一个视图控制器。我在ios上解决了这个问题:
//runningService.stopit();
// OR
stopService(RunningService); // user called
boolean iStopped = true;
public void stopit(){
//stopSelf();
}
public void onDestroy(){
super.onDestroy();
if(iStopped){
// user did it
}else{
// system did it
}
iStopped = false; // whoever did it , reset it
}
但是在tvOS上,这个解决方案并不起作用,我也不知道为什么。当我双击快速时,我有几个过渡。请帮忙
class ViewController: UIViewController, UINavigationControllerDelegate {
var segueInProgress: Bool?
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.delegate = self
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
return segueInProgress == false
}
func navigateShow(to viewController: UIViewController, sender: Any? = self) {
if self.segueInProgress == true { return }
if let navigationController = self.navigationController {
navigationController.show(viewController, sender: sender)
} else {
self.show(viewController, sender: sender)
}
}
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
// Or like this: self.view.isUserInteractionEnabled = false
self.segueInProgress = true
}
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
self.segueInProgress = false
// Or like this: self.view.isUserInteractionEnabled = true
}
}
答案 0 :(得分:0)
你可以在按下之后禁用按钮,这会阻止用户双击,只需确保如果你需要担心状态回到你的ViewController,你就可以在viewWillAppear上启用它。