uialertcontroller

dismissViewControllerAnimated does not work within a block

家住魔仙堡 提交于 2019-11-30 14:56:54
问题 I try to close a UIViewController after an UIAlertController has been shown. This is my code: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Accept" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self dismissViewControllerAnimated:YES completion:nil]; }]; [alertController addAction:okAction]; [self

How to add UIImageView in UIAlertController?

删除回忆录丶 提交于 2019-11-30 14:02:00
I want UIAlertController to present an alert with UIImageView in an ActionSheet . But when I run the application it is terminating. This is my code: UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"Welcome" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okButton = [UIAlertAction actionWithTitle:OK style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }]; [alert addAction:okButton]; UIImageView *imgv = [[UIImageView alloc]initWithFrame:CGRectMake(20,20,50,50)]; imgv.image = [UIImage imageNamed:@"kaga.jpg"]; [alert setValue:imgv

How do I access the input from my text field in UIAlertController with objective c?

我只是一个虾纸丫 提交于 2019-11-30 13:45:43
问题 I'm changing everything over from AlertView to AlertController, but I can't find anything online for objective c that retrieves what the user inputs in a text field for the AlertController. Here is what I have: if ([UIAlertController class]) { UIAlertController *alertControllerK2 = [UIAlertController alertControllerWithTitle:@"\u00A0" message:@"Please enter the first number." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *K2okAction = [UIAlertAction actionWithTitle:@"OK" style

Unable to choose order of buttons in UIAlertController

时间秒杀一切 提交于 2019-11-30 12:44:07
I was under the impression that if the normal action is a destructive action and the other is a cancel action in their UIAlertController that the destructive one should be on the left and the cancel should be on the right. If the normal action is not destructive, then the normal action should be on the right and the cancel should be on the left. That said, I have the following: var confirmLeaveAlert = UIAlertController(title: "Leave", message: "Are you sure you want to leave?", preferredStyle: .Alert) let leaveAction = UIAlertAction(title: "Leave", style: .Destructive, handler: { (alert:

How to hide title/message frame in a UIAlertController?

余生长醉 提交于 2019-11-30 11:17:00
问题 When using a UIAlertController , if I want to present a UIActionSheet with an empty title and an empty message, the frame for the expected placement of the title and/or message remains. How do I change this so that I only present an ActionSheet that reads: Settings Sign out Cancel ? Thanks! 回答1: When I create a UIAlertController with this code I don't have the title spacing. [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; Are you

Leaks with UIAlertController

假装没事ソ 提交于 2019-11-30 11:09:38
I added UIAlertController in my app by creating a category on UIViewController with the following method: - (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message actions:(NSArray *)alertActions { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title ? : @"" message:message preferredStyle:UIAlertControllerStyleAlert]; if (alertActions.count) { for (UIAlertAction *action in alertActions) { [alertController addAction:action]; } } else { UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];

UIAlertController tint color defaults to blue on highlight

有些话、适合烂在心里 提交于 2019-11-30 10:49:41
I'm use the following code to present a UIAlertController action sheet with the item text as red. I've used the tint property to set the color. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; alertController.view.tintColor = [UIColor redColor]; The text color seems to be defaulting to blue on highlight or selection. Is this normal and how do I stop this? This is a known Bug, see https://openradar.appspot.com/22209332 To fix it, reapply the tint color in the Completion handler. Here's my Swift

Xcode Swift how to add image to UIAlertController options? [duplicate]

北城以北 提交于 2019-11-30 10:32:43
This question already has an answer here: Add Image to UIAlertAction in UIAlertController 7 answers i want to add image/icon to UIAlertController like the dialog inside apple music player what i want colored/sized image/icon like the image below, not like the one inside this question .i believe its ios 11+ feature but i can't find the documents for it . exactly like this : can i do this in UIAlertController or i should make my own custom dialog uiviewcontroller ? let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) alert.modalPresentationStyle = .popover let

How to create Custom UIAlertController in swift ios?

浪尽此生 提交于 2019-11-30 07:44:16
I am trying to make UIAlertController that looks like this: How can we customize the UIAlertController to get the result something same as this picture ? What you are trying to do is a popover, for current versions of iOS you can achieve the same effect for both iPad and iPhone. 1.- Start by building your design on Storyboard or a xib. and then reference it. 2.- then present it as a popover. 3.- maybe you will want to implement popoverdelegates to avoid wrong positions when rotating the device. for example: private static func presentCustomDialog(parent: UIViewController) -> Bool { /// Loads

UIAlertAction Button Text Alignment Left

纵饮孤独 提交于 2019-11-30 07:43:53
I want to align UIAlertAction text alignment to Left and add the icon as in image shown. I spent lot of time on google to get the solution but not found the right answer. Every body post for the alert title not for the alert action title. Please suggest me the right way for swift . Thanks!! Niraj Solanki You can do that with bellow example code. Easy and Simple. Swift 4 let actionSheetAlertController: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) let cancelActionButton = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)