Skip to content

Instantly share code, notes, and snippets.

@alldritt
Last active May 28, 2017 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alldritt/20944d8c93a8d369f511699d4e4c0165 to your computer and use it in GitHub Desktop.
Save alldritt/20944d8c93a8d369f511699d4e4c0165 to your computer and use it in GitHub Desktop.
Eureka Form within UIAlertController
override func viewDidLoad() {
form
+++ Section("Testing")
<<< ButtonRow("alert") { (row) in
row.title = "Eureka Alert"
}
.onCellSelection { [weak self] (cell, row) in
let vc = FormViewController()
vc.form
+++ Section("Section 1") { section in
section.header?.height = { return 36 }
}
<<< LabelRow() { row in
row.title = "Label"
row.value = "Value"
}
<<< SwitchRow() { row in
row.title = "Switch 1"
}
<<< SwitchRow() { row in
row.title = "Switch 2"
}
+++ Section("Section 2") { section in
section.header?.height = { return 18 }
}
<<< SwitchRow() { row in
row.title = "Switch 3
}
<<< SwitchRow() { row in
row.title = "Switch 4"
}
vc.edgesForExtendedLayout = []
vc.preferredContentSize = CGSize(width: 300, height: 252)
let alert = UIAlertController(title: "Alert Title",
message: "Alert Message Text",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
// This call is potentially problematic since it exploits an undocumented API but I cannot
// find another way to make this work.
alert.setValue(vc, forKey: "contentViewController")
self?.present(alert,
animated: true,
completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment