[ad_1]
I’m making a mock DVR distant that may create an error pop-up if the consumer selects two buttons in a row that aren’t allowed (Pausing, fast-forwarding
or rewinding is just doable when the DVR is within the Taking part in state.
d. The “File” button will begin recording. Recording can solely begin when the
DVR is within the Stopped state. Taking part in, pausing, fast-forwarding or rewinding shouldn’t be
doable when the DVR is within the Recording state.
e. The “Cease” button will cease any operation.)
I wrote a perform to tug up the alert if one among these actions is violated, however I am having bother getting the textual content to correctly show within the label and I’m having bother with the alerts arising. Can anybody inform me why?
func alert(){
let title = "Error"
let message = "That motion shouldn't be allowed."
let alertController =
UIAlertController(title: title,
message: message,
preferredStyle: .alert)
var actions: [UIAlertAction] = []
let cancelAction =
UIAlertAction(title: "Cancel",
fashion: .cancel,
handler: nil)
let okayAction =
UIAlertAction(title: "Proceed anyway",
fashion: .default) { _ in
let confirmAlertController = UIAlertController(title: "Are you certain?",
message: nil,
preferredStyle: .alert)
confirmAlertController.addAction(UIAlertAction(title: "Verify", fashion: .default, handler: nil))
self.current(confirmAlertController,
animated: true,
completion: nil)
}
actions += [ cancelAction, okayAction ]
for motion in actions {
alertController.addAction(motion)
}
current(alertController,
animated: true,
completion: nil)
}
@IBAction func DVRbuttons(_ sender: UIButton) {
var previousSetting = DVRstate.textual content
if let textual content = sender.currentTitle{
if textual content == "Cease"{
DVRstate.textual content = "State: Stopped"
}
if textual content == "Play"{
if previousSetting == "State: Recording"{
alert()
}else{
DVRstate.textual content = "State: Taking part in"
}
if textual content == "Pause"{
if previousSetting == "State: Taking part in"{
DVRstate.textual content = "State: Paused"
}else{
alert()
}
}
if textual content == "FFW"{
if previousSetting == "State: Taking part in"{
DVRstate.textual content = "State: Quick Forwarding"
}else{
alert()
}
}
if textual content == "FRW"{
if previousSetting == "State: Taking part in"{
DVRstate.textual content = "State: Quick Rewinding"
}else{
alert()
}
}
if textual content == "File"{
if previousSetting == "State: Stopped"{
DVRstate.textual content = "State: Recording"
}else{
alert()
}
}
}
}
}
[ad_2]
