-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextAlert.lua
More file actions
34 lines (26 loc) · 1.07 KB
/
TextAlert.lua
File metadata and controls
34 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
TextAlert = class()
function TextAlert:init(title, message, actionTitle)
self.title = title
self.message = message
self.actionTitle = actionTitle or "Submit"
end
function TextAlert:present(result)
local alertController = objc.UIAlertController()
alertController.title = self.title
alertController.message = self.message
alertController.preferredStyle = objc.enum.UIAlertControllerStyle.alert
function submitPressed(objAction)
local field = alertController.textFields[1]
if result ~= nil and field ~= nil then
result(field.text)
end
end
local action = objc.UIAlertAction:actionWithTitle_style_handler_(self.actionTitle, objc.enum.UIAlertActionStyle.default, submitPressed)
alertController:addAction_(action)
alertController:addTextFieldWithConfigurationHandler_(nil)
objc.viewer:presentViewController_animated_completion_(alertController, true, nil)
end
function createAlertBox(title, message, func)
myAlert = TextAlert(title, message)
myAlert:present(func)
end