uialertaction

SwiftUI: UIAlertController's textField does not responding in UIAlertAction

人盡茶涼 提交于 2020-07-03 11:41:11
问题 I need to use UIAlertContoller , as SwiftUI's Alert does not support TextField . I must not use Custom created AlertView, due to various reason(Accessibility, DynamicType, Dark Mode support etc). Basic Idea is, SwiftUI's alert must hold TextField & entered text must be reflect back for usage. I created a SwiftUI view by Conforming to UIViewControllerRepresentable following is working code. struct AlertControl: UIViewControllerRepresentable { typealias UIViewControllerType = UIAlertController

SwiftUI: UIAlertController's textField does not responding in UIAlertAction

北城余情 提交于 2020-07-03 11:40:03
问题 I need to use UIAlertContoller , as SwiftUI's Alert does not support TextField . I must not use Custom created AlertView, due to various reason(Accessibility, DynamicType, Dark Mode support etc). Basic Idea is, SwiftUI's alert must hold TextField & entered text must be reflect back for usage. I created a SwiftUI view by Conforming to UIViewControllerRepresentable following is working code. struct AlertControl: UIViewControllerRepresentable { typealias UIViewControllerType = UIAlertController

Get handler of UIAlertAction in Swift

倖福魔咒の 提交于 2020-05-29 11:29:35
问题 How is it possible to get the handler of a UIAlertAction in Swift. It is set when initializing however I haven't found any property to get hold on the closure of the action. The closure is of type (UIAlertAction) -> Void however I would like to get the content of the closure so that I have some closure like () -> Void . Is this possible? Thanks for your answers 回答1: There is NO member/property exposed by the UIAlertAction class. However we can manage this by ourselves by subclassing

Get handler of UIAlertAction in Swift

浪尽此生 提交于 2020-05-29 11:28:01
问题 How is it possible to get the handler of a UIAlertAction in Swift. It is set when initializing however I haven't found any property to get hold on the closure of the action. The closure is of type (UIAlertAction) -> Void however I would like to get the content of the closure so that I have some closure like () -> Void . Is this possible? Thanks for your answers 回答1: There is NO member/property exposed by the UIAlertAction class. However we can manage this by ourselves by subclassing

Add multiple line text to UIAlertAction in correct size

不羁岁月 提交于 2020-05-14 10:55:34
问题 I'm showing the 2 text values in UIAlertAction. I used the following code. UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).numberOfLines = 0 let actionSheetController = UIAlertController(title: nil, message: "Call", preferredStyle: .actionSheet) actionSheetController.view.tintColor = UIColor.red for key in phoneNumbers.keys { let phoneNumber = phoneNumbers[key] ?? "" let actionTitle = "\(key)\n\(phoneNumber)" let phoneNumberAction = UIAlertAction(title: actionTitle,

UIAlertAction list of values

让人想犯罪 __ 提交于 2020-05-11 06:41:12
问题 I'm trying to figure out how to change font type for UIAlertAction title. I'm assuming, it can be done by setting a value for particular key. For instance, to set an image you would do this: action.setValue(image, forKey: "image") Is there a list of all keys that are available? I can't figure out which key to use for changing font, aligning the title left/right, etc... 回答1: class_copyIvarList may be what you need. Swift extension UIAlertAction { static var propertyNames: [String] { var

How can I perform the handler of a UIAlertAction?

a 夏天 提交于 2019-12-22 08:44:29
问题 I'm trying to write a helper class to allow our app to support both UIAlertAction and UIAlertView . However, when writing the alertView:clickedButtonAtIndex: method for the UIAlertViewDelegate , I came across this issue: I see no way to execute the code in the handler block of a UIAlertAction . I'm trying to do this by keeping an array of UIAlertAction s in a property called handlers @property (nonatomic, strong) NSArray *handlers; and then implement a delegate like such: - (void) alertView:

Should self be captured as strong in a UIAlertAction's handler?

瘦欲@ 提交于 2019-12-20 08:44:50
问题 When writing the handler closure of a UIAlertAction , should the reference to self be strong (the default), weak , or unowned ? There have been posts relevant to this topic (1, 2, 3, 4) but I honestly don't see how they help in this case. Let's focus on this typical code: func tappedQuitButton() { let alert = UIAlertController(title: "Confirm quit", message: nil, preferredStyle: .ActionSheet) let quitAction = UIAlertAction(title: "Quit", style: .Default) { (action) in self