Working with time interval in view?

Friends, help Council for proper implementation

There is a view, where by clicking and viewing ads, the next press is possible only after a period of time.

If the user remains in this view, this time period is passing your interval does not open the accessibility button is pressed. Only re-entry in this view will give you the opportunity
June 5th 19 at 21:07
1 answer
June 5th 19 at 21:09
Solution
Well, after the first time do view.isUserInteractionEnabled = false and in the method viewWillDisappear set a flag to true. This method is invoked when a person leaves the controller in which is view. Save somewhere this flag, or make it global for all controllers. Well, in the following entry, checking this flag will return isUserInteractionEnabled. If he did not go anywhere, then moisture above won't give click.
Good. Thank you for your comments, all right. But if he stays in view, then without rebooting I have not read the rest of the time. I put so next time you can click knokw in 15 minutes, and even if this time has passed, it's not working only if you go back and back to back view - alana.Dibbert75 commented on June 5th 19 at 21:12
I do not understand. What's the problem? As time passed, I looked at the flag and changed the user to connect. - alycia_Pfannerstill commented on June 5th 19 at 21:15
I will try your code
// MARK: Telegram Share
 @objc func sharetoTg() {
 if dateToday.isGreater(than: vc.defaults.value(forKey: "NextDay4") as! Date) {
 tbShare.nextDay4 = Date(timeInterval: dateInterval, since: dateToday)
...
 let alert = UIAlertController(title: nil, message: "Share on Telegram".localized, preferredStyle: .alert)
 let action = UIAlertAction(title: "Done".localized, style: .default) { (action) in
...
}
alert.addAction(action)
...
 } else {
 let alert = UIAlertController(title: nil, message: "You can share ".localized + "after 15 minutes")", preferredStyle: .alert)
 let action = UIAlertAction(title: "OK".localized, style: .default)
alert.addAction(action)
 self.present(alert, animated: true, completion: nil)
}
 }


5b0013b1d9507926062001.png

Before my function runs, knock is triggered method to compare two time values. And while the user is in this view, time of the compared values is not read. I.e. clicking again on the button to view the ads, he saprien show in the framework conditions, i.e., the next push after 15 minutes, but then when the 15 minutes pass, he is alert, and the button does not work. And as soon as it comes out and drop from this view, then compare the value updates its performance and allows the touch of a button. - alana.Dibbert75 commented on June 5th 19 at 21:18
DateToday can withdraw and what you have stored in the user defaults.at the expiration of the term. Right before the conditional if statement - alycia_Pfannerstill commented on June 5th 19 at 21:21
Perfectly and Elementary. Thank you. - alana.Dibbert75 commented on June 5th 19 at 21:24

Find more questions by tags Swift