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

Repeating Audio playback with AVAudioPlayer

隐身守侯 提交于 2020-05-17 06:29:05
问题 I'm using AVAudioPlayer and want that the user can restart the playback once the loop is played back. For the user feedback I used UIAlertController but I still struggle to get the replay done with AVAudioPlayer. I want that the user can choose replay as often as he like until he choose NO. Here is my code I have so far, but what to do if the user select YES ... see comment in code below. // schedule the audio file [self->_playerNode scheduleFile:self->_file atTime:nil completionHandler:^{

iOS13 UIAlertController with custom view & preferredStyle as actionsheet grayscale all colors

天大地大妈咪最大 提交于 2020-05-16 03:39:08
问题 I'm not exactly sure if it's a bug or a feature, but this code: let sheet = UIAlertController(customView: awesomeView, preferredStyle: .actionSheet) .... present(sheet, animated: true, completion: nil) in pre-iOS 13 gives me this result: and on iOS 13: I.e. all the customview's elements have been grayscale. I've tried to play with Tint/Text/Background/... colors of the buttons / label - in iOS 13 is does no effect at all. In older versions - UI is changing. The goal: to avoid the grayscale

App crash when presenting UIAlertController [duplicate]

别说谁变了你拦得住时间么 提交于 2020-05-15 08:39:07
问题 This question already has answers here : Swift UIAlertController -> ActionSheet iPad iOS8 Crashes (8 answers) Closed 2 years ago . My app's crashing when trying to present a UIAlertController . I have a UIViewController that gets presented modally, then on that presented view controller when a certain button is tapped I want to present a actionSheet alert. Somehow the app crashes when doing this and I cannot figure it out why. Here's the code: let alertController = UIAlertController(title:

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,

iOS13.1 UIAlertController with preferedStyle: .actionSheet cannot change title's text color and font

元气小坏坏 提交于 2020-03-05 04:25:26
问题 I change title font and color like this: let titleAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Bold", size: 25)!, NSAttributedStringKey.foregroundColor: UIColor.purple] alert.setValue(titleString, forKey: "attributedTitle") Before iOS13 this worked fine both for preferredStyle .alert and .actionSheet. Now it only works for .alert and doesn't work for .actionSheet. Someone please any help? 回答1: iOS 13 now embeds the UIAlertController title in a UIVisualEffectView, and

Swift UIAlertController with url in text

痴心易碎 提交于 2020-02-24 16:16:30
问题 I have this code: func alertBox(txt: String){ let ac = UIAlertController(title: "MyTtle" , message: "More information in my website: ", preferredStyle: .alert) let ramkaNaObrazek = CGRect(origin: CGPoint(x: 10, y: 10), size: CGSize(width: 30, height: 30)) let ikonaAlertu = UIImageView(frame: ramkaNaObrazek) ikonaAlertu.image = UIImage(named: "modal_podpowiedz") ac.view.addSubview(ikonaAlertu) ac.addAction(UIAlertAction(title: "Ok" , style: .cancel, handler: { (action: UIAlertAction!) in }))

display UIAlert will crash the app on present?

≡放荡痞女 提交于 2020-02-24 11:40:26
问题 I have a test connection action logic. it will test the server in live or not. the bug happens when the logic finishes the test and try display UIAlertController inside closure thread it will crash the systems. @IBAction func TestNetwork(_ sender: Any) { var message = "\(internetConnection) internet connection \n \(serverStatus) server\n " self.showSpinner(onView: self.view) DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { self.testConnection(connectionTestCompletionHanlder:

Why alamofire downloads progress in alert will flashing and the behind screen starts to be fade to black?

喜你入骨 提交于 2020-02-05 04:55:05
问题 I have progress view in alert when downloading with alamofire, but the problem is that when I want to download the progress view in alert will start to be complete but flashing and the other problem is that the behind screen will start to be fade to black I think in every second a new alert with progress view will show and at the end there are lots of alerts how can I avoid them? downloadTimer = Timer.scheduledTimer(timeInterval: 1 , target: self, selector: #selector(flashingDownload),