uialertcontroller

UIAlertController customization

天涯浪子 提交于 2019-12-02 17:36:52
问题 I'm trying to customize my UIAlertController with a dark theme. I'm aiming for something like this I'm trying different things, including the suggestion I found here https://stackoverflow.com/a/29122883/1817873, but for some reason only the first button gets colored while the cancel button keeps staying white. Here is my code: UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *deleteAction =

Swift writing a function that takes self as an input

强颜欢笑 提交于 2019-12-02 17:23:11
问题 I have alert that is being fired from different location so I decided to make a function to be called. func alertSCFlag(x: Int) { var alert = UIAlertController() switch x { case 1: alert = UIAlertController(title: "Not Finished", message: "sorry but you must give the project a title and description", preferredStyle: UIAlertControllerStyle.alert) default: alert = UIAlertController(title: "Not Finished", message: "sorry but you need to choose a type of project", preferredStyle:

UIAlertController's actionSheet gives constraint error on iOS 12.2 / 12.3 [duplicate]

☆樱花仙子☆ 提交于 2019-12-02 16:35:25
This question already has an answer here: Swift default AlertViewController breaking constraints 1 answer On iOS 12.2. while using UIAlertController's actionSheet Xcode, gives constraint error anyone having this problem This same code runs on iOS 12.1 with no error I have tested this code on Xcode 10.2 and 10.1 class ViewController: UIViewController { let Click : UIButton = { let button = UIButton(type: UIButton.ButtonType.system) button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("OK", for: .normal) button.tintColor = UIColor.blue button.addTarget(self, action: #selector

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

早过忘川 提交于 2019-12-02 16:34:11
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.dismissViewControllerAnimated(true, completion: nil) } alert.addAction(quitAction) let cancelAction = UIAlertAction

VoiceOver Z gesture won't trigger when UIAlertController is active

ε祈祈猫儿з 提交于 2019-12-02 13:56:37
问题 I'm trying to use the Z gesture to dismiss a UIAlertController. I have a very simple app. It has a single view with 1 button. Tapping the button presents an alert. I have implemented - (BOOL)accessibilityPerformEscape { NSLog(@"Z gesture"); return YES; } With VoiceOver on, scrubbing the screen prints out "Z gesture," but when I press the button and the alert is visible, scrubbing the screen does nothing, the method is not called and nothing is printed. What do I have to do to get this to

How to put an image on UIActionSheet?

落花浮王杯 提交于 2019-12-02 13:36:42
How to put image on UIActionSheet on right position of text. Like given in apple music player. Note: Don't answer with custom view, if it is possible in UIActionSheet , Kindly let us know. Don't answer with custom view Then you are effectively forbidding anyone to answer, because that is what you do . First of all, there is no such thing as UIActionSheet. It was deprecated four years ago. Today we use UIAlertController. UIAlertController is nothing but a prepackaged presented view controller. It does nothing that you could not do for yourself. It is also deliberately very simple and limited.

UIAlertController visible only when viewDidAppear has finished its call

柔情痞子 提交于 2019-12-02 12:32:52
问题 I am trying to show a UIAlertController as my view loads. I know that's impossible during viewDidLoad() or viewWillAppear() because the view is not in the hierarchy at during the execution of those functions. However, if the view is added before viewDidAppear() , then it should be possible to show my UIAlertController during the call of that function. Therefore, I tried this: override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) var AlertShow = false print(Configuration)

Calling UIAlertController inside a UITableViewCell

一世执手 提交于 2019-12-02 11:27:22
I am trying to call a UIAlertController from within my UITtableViewCell when my function is called. It gives me an error saying present is not available. I understand it's not within a ViewController . I am looking for an approach to access it. override func awakeFromNib() { super.awakeFromNib() // Initialization code let tapGestureShareImageView = UITapGestureRecognizer(target: self, action: #selector(self.shareImageTouchUpInside)) shareImageView.addGestureRecognizer(tapGestureShareImageView) shareImageView.isUserInteractionEnabled = true } @objc func shareImageTouchUpInside() { showAction()

Swift - How to present ViewController when tapping button in a custom AlertController

谁都会走 提交于 2019-12-02 10:33:12
I am developing in Swift 2.3 I have an Utils class enabling me to create UIAlertController easily. public class Utils { class func buildAlertInfo(withTitle title: String?, andMessage message: String?, withHandler handler: (UIAlertAction -> Void)?) -> UIAlertController { let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: handler)) return alertController } } It enables me to build AlertController with ease : let alert = Utils

progress view in alamo fire will not update when downloading file in swift 3

橙三吉。 提交于 2019-12-02 10:01:50
I want to download a file with alamo fire and using alert with progress to show it but the progress will not move when alamo fire progress.fractionCompleted increased I use static var to equal progres.fractionCompleted but it doesn't worked too here is my codes let destination = DownloadRequest.suggestedDownloadDestination() Alamofire.download("example.com", to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in print("Progress: \(progress.fractionCompleted)") sixthLevelViewController.progressdownload = Float(progress.fractionCompleted) DispatchQueue.main