Last active
May 28, 2017 23:16
-
-
Save alldritt/20944d8c93a8d369f511699d4e4c0165 to your computer and use it in GitHub Desktop.
Eureka Form within UIAlertController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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