【发布时间】:2019-06-16 23:16:21
【问题描述】:
我试图隐藏一个按钮,直到满足另一个条件。当我加载应用程序时,我正在使用滑块并且当它达到最大值时,它应该使按钮可见,但由于某些奇怪的原因它不会。我刚刚在另一个没有问题的应用程序中完成了它,代码几乎相同。?
不知道该怎么办。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
profileVisible.isHidden = true
}
@IBAction func btnClicked(_ sender: Any) {
motionManager.startDeviceMotionUpdates(to: queue) { (motion, error) in DispatchQueue.main.async {
self.slider.value = Float((motion?.attitude.roll ?? 0 ) * 1.4)
print(self.slider.value)
if self.slider.value == 1.0 {
self.profileVisible = false
self.motionManager.stopDeviceMotionUpdates()
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); // vibrates when payment has succeded
}
if self.slider.value == -1.0 {
profileVisible = true
self.motionManager.stopDeviceMotionUpdates()
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
}
}
}
【问题讨论】: