This commit is contained in:
Tina 2017-07-10 12:08:08 -07:00
Родитель 6a480eb989
Коммит 241aa7e103
2 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -21,7 +21,7 @@ class AnalyticsViewController: UIViewController {
case customEventButton:
print("TODO: send a custom alert via Cocoapods")
presentCustomEventAlert()
case customColorButton:
print("custom color property button pressed")
presentColorPropertyAlert()
@ -30,49 +30,49 @@ class AnalyticsViewController: UIViewController {
break
}
}
// - MARK: Alert Functions
func presentCustomEventAlert() {
let alert = UIAlertController(title: "Event sent",
message: "",
preferredStyle: UIAlertControllerStyle.alert)
// OK Button
alert.addAction(UIAlertAction(title: "OK",
style: UIAlertActionStyle.default,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
handler: { _ in alert.dismiss(animated: true, completion: nil)
}))
self.present(alert, animated:true, completion: nil)
present(alert, animated: true, completion: nil)
}
func presentColorPropertyAlert() {
let alert = UIAlertController(title: "Choose a color",
message: "",
preferredStyle: .alert)
alert.view.tintColor = UIColor.black
// Yellow button
alert.addAction(UIAlertAction(title: "Yellow",
style: .default,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
handler: { _ in alert.dismiss(animated: true, completion: nil)
}))
//TODO: send yellow event here
// TODO: send yellow event here
// Blue button
alert.addAction(UIAlertAction(title: "Blue",
style: .default,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
handler: { _ in alert.dismiss(animated: true, completion: nil)
}))
//TODO: send blue event here
// TODO: send blue event here
// Red button
alert.addAction(UIAlertAction(title: "Red",
style: .default,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
handler: { _ in alert.dismiss(animated: true, completion: nil)
}))
//TODO: send Red event here
self.present(alert, animated:true, completion: nil)
// TODO: send Red event here
present(alert, animated: true, completion: nil)
}
}

Просмотреть файл

@ -17,25 +17,25 @@ class CrashViewController: UIViewController {
@IBAction func crashButtonTapped(_: UIButton) {
presentCrashAlert()
}
//- MARK: Alert Functions
// - MARK: Alert Functions
func presentCrashAlert() {
let alert = UIAlertController(title: "The app will close",
message: "A crash report will be sent upon RE-LAUNCHING the app.",
preferredStyle: UIAlertControllerStyle.alert)
// Cancel Button
alert.addAction(UIAlertAction(title: "Cancel",
style: UIAlertActionStyle.default,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
handler: { _ in alert.dismiss(animated: true, completion: nil)
}))
// Crash App button
alert.addAction(UIAlertAction(title: "Crash app",
style: UIAlertActionStyle.destructive,
handler: { (action) in alert.dismiss(animated: true, completion: nil)
fatalError()
handler: { _ in alert.dismiss(animated: true, completion: nil)
fatalError()
}))
self.present(alert, animated:true, completion: nil)
present(alert, animated: true, completion: nil)
}
}