FAQ Database Discussion Community


Calling presentViewController from custom class

swift,uialertcontroller
I read this post and this one on how to call a presentViewController form outside a UIViewController subclass. In my case, the custom class is a subclass of NSObject. The following approach is the only one that works (from the examples I read): UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil) My question:...

boolean field UIAlertController swift

ios,iphone,swift,uialertcontroller
Is there any way I can have a 'Boolean' field in an .Alert style UIAlertController or may be convert any of the available fields that can be added to .Alert into a 'Bool' value when reading the value from the field?

How to dismiss UIAlertController when tap outside the UIAlertController?

ios,uialertview,uialertcontroller
How to dismiss UIAlertController when tap outside the UIAlertController? I can add a UIAlertAction of style UIAlertActionStyleCancel to dismiss the UIAlertController. But I want to add the function that when user tap outside the UIAlertController the UIAlertController will dismiss. How to do that? Thank you....

How to parse a RSS feed using NSXMLParser with variables on the feed address by pressing a button in a UIAlertController Alert in Swift?

ios,swift,nsxmlparser,uialertcontroller
I have been trying to integrate a Pinboard bookmarks view (by parsing an RSS Feed and displaying it in a UITableView) in my browser app, and I'm encountering a few issues. You can see my previous questions here and here. I'm trying to use the variables I collected from my...

Presenting a UIAlertController from a modally presented controller that is being dismissed

objective-c,uiviewcontroller,ios8,modal-dialog,uialertcontroller
Prior to iOS 8, a UIAlertView could be displayed from a modally presented UIViewController at the same time that the UIViewController was dismissed. I found this to be especially useful when a user needed to be alerted to some change that had taken place when they pressed the 'Save' button...

UIAlertAction completion block not called - iOS

ios,objective-c,cocoa-touch,uiactionsheet,uialertcontroller
I have an iOS app with a UIAlertController in the form of a action sheet being presented in my app when the user taps on a button. It all works great, apart from one thing, the completion blocks don't get called for some reason. Here is my code: // Setup...

What is the difference between UIAlertActionStyleDestructive and UIAlertActionStyleCancel?

ios,objective-c,uialertcontroller
UIAlertActionStyleDestructive and UIAlertActionStyleCancel seem very similar to me. According to the documentation: UIAlertActionStyleCancel: Apply a style that indicates the action cancels the operation and leaves things unchanged. and UIAlertActionStyleDestructive: Apply a style that indicates the action might change or delete data. Regardless of style, the action will still have a...

checkbox in uialertview in ios8

ios,iphone,checkbox,uialertview,uialertcontroller
I want to add checkbox exactly as the below image below is my code: UIButton *nameField = [[UIButton alloc] initWithFrame:CGRectMake(120, 0, 30, 30.0)]; UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 50)]; [v setBackgroundColor:[UIColor clearColor]]; [nameField setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal]; [v addSubview:nameField]; UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Delete selected pods from...

UiAlertView or UiAlertController to display only once in Swift

swift,uialertview,uialertcontroller
How can I get my UiAlertController or UIAlertView to display only once in Swift? override func viewDidLoad() { var defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults() if let nameIsNotNill = defaults.objectForKey("name") as? String { self.name.text = defaults.objectForKey("name") as String } if let phoneIsNotNill = defaults.objectForKey("phone") as? String { self.phone.text = defaults.objectForKey("phone") as String...

Swift: Adding UITextView in UIAlertController

ios,swift,uialertcontroller
I am familiar with addTextFieldWithConfigurationHandler to add text field in UIALertController of .Alert style. But I am trying to make a feedback form inside the alert and it needs multiple lines of text entry. I cant find a corresponding addTextViewWithConfigurationHandler Are there any workarounds?...

How do i get a value of textField in an UIAlertController?

ios,swift,uialertcontroller
I'm trying to get a textField value from UIAlertController, but whenever I try to enter the value and try to print it out, the output doesn't show anything. code: var alert = UIAlertController(title: "Enter the password", message: "Message", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil)) alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in textField.placeholder...

iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

ios,swift,keyboard,uitextfield,uialertcontroller
The context is pretty simple, there is a UIViewcontroller with a textfield to enter a phone number. The textfield is in editing mode with keyboard. When the number is entered, the user can tap a button which displays an alert controller. As the alert is presented modally it covers the...

How to detect whether UIAlertView is currently showing

ios,objective-c,uialertview,uialertcontroller
Is there any way to judge whether there is currently a UIAlertView instance showing? Because it is possible to show multiple UIAlertView in the same window level. if ([self isAlertViewShowing]) { // do not show UIAlertView again. } else { // show your UIAlertView. } Hope there is such a...

How do we create and dismiss an UIAlertController without user input? (Swift)

swift,uiviewcontroller,uialertcontroller
I've been looking up a lot of tutorials on UIAlertController. Thus far, the way I found was to activate a UIAlertController by linking it to a button or label and then call a IBAction. I tried to replicate the code to automatically pop an alert when user enters the app...

trying to do a rate us UIAlertController

ios,iphone,swift,uialertcontroller
Whenever I run my app the following error is called Warning: Attempt to present "The alert" on "MenuViewController" whose view is not in the window hierarchy! what exactly does this mean and how do I fix it? I only have one UIViewController and here it is class MenuViewController: UIViewController {...

ActionSheet Source View BarButtonItem

ios,swift,uibarbuttonitem,uialertcontroller,uipopover
I have a bar button item in the navigation bar that when pressed, will present a UIAlertController with the style as .ActionSheet. In the iPhone it appears just the way that I want. For the iPad I know I need to add // For iPad, set the pop over bounds...

One UIAlertController function with multiple actions - is this possible?

ios,swift,segue,uialertcontroller
The following code is for a function I wrote to handle the 'Back' button and the 'Logout' button. When the user taps 'Cancel', he will stay on the current view, when he taps 'OK' he will be taken to either the previous view or the login screen, depending on which...

How to make data I enter in a UITextField inside a UIAlertController persist through resets in Swift?

ios,swift,uitextfield,uialertcontroller
I have been trying to integrate a Pinboard bookmarks view (by parsing an RSS Feed and displaying it in a TableView) in my browser app. To get the username and API Token for the feed I have a UIAlertController in the Settings view of my app. The details entered are...

Loop over multiple UIAlertController's

swift,synchronization,uialertcontroller
In some cases my applications needs to display muliple Alert messages. Error messages are gathered on start and needs to be displayed to the user one at a time. When the first one is acknowledged, the next one should be presented. The problem is that they all try to execute...

how to apply Music Radio loading in UIAlertController?

swift,loading,uialertcontroller
I want to create this loading style in my project,i really dont know how.I am really a beginner to swift ui components.I want to add this loading style in my alert view and after getting the results i want to dismiss.So,i want to know about how to make it and...

How do I code an UIAlertAction in Swift?

ios,swift,uialertcontroller
I would like to reproduce the following UIAlertAction in Swift: @IBAction func buttonUpgrade(sender: AnyObject) { let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in // ... } alertController.addAction(cancelAction) } I'm aware that an UIAlertController is initialized with a title, message,...

How to display AlertController in UiView

ios,swift,uiview,uialertcontroller
new to Swift. Below code is executed without error but in the console it show some message. Is this error message, how to fix it? Is this required to be fixed when sending app for certification. Thanks this is my App structure : VC(1) --> goto --> VC(2) In VC(1)...

How should I issue an alert that times out in swift

swift,uialertcontroller
I am using a UIAlertController to display a user alert that requires a user action. I would like to skip the user action and make the alert disappear after some time (say 10 seconds). What is the best approach to do that?

How do I add rows to UIPickerView from UIAlertController

iphone,uipickerview,uialertcontroller
I have a UIPickerView that gets its data from an array that is defined in friends = [NSArray arrayWithObjects: @"jim", @"joe", @"anne", nil]; I have a button under the picker that is supposed to add new friends to the picker. When the button is pressed a UIAlertController pops up and...

What is the best way to check if a UIAlertController is already presenting?

ios,uialertcontroller
I have a tableview which, when loaded, each cell could possibly return an NSError, which I have chosen to display in a UIAlertController. Problem is I get this error in the console if multiple errors are returned. Warning: Attempt to present UIAlertController: 0x14e64cb00 on MessagesMasterVC: 0x14e53d800 which is already presenting...

Action on UIAlertController that does not dismiss AlertController? (Disable dismissing)

ios,objective-c,cocoa-touch,uiviewanimationtransition,uialertcontroller
I have an action sheet (UIAlertController with style of UIAlertControllerStyleActionSheet) with a few actions, presented on an iPad as a popover. What I want is, when a user selects one of the options (say, the first one), I want the action sheet to transition to a different action sheet, using...

UialertController to show only once when the var hits an certain Value

ios,swift,uialertcontroller
so the way my app works is you tap on a cell , a var value gets modified (+1 for example). I've figured out how to get a UIalert to pop when my var reaches a certain value (10). But now everytime I update the var the alert pops. What...

How to call my custom alert controller function to display in other view controller?

ios,swift,uialertcontroller
I have write my custom alert view controller.But,I am having error at calling my alert controller from other view controller.It show me the error that I described below. Error on console 2015-06-15 10:21:50.610 automobile[4197:62165] Warning: Attempt to present <UIAlertController: 0x7d11cf70> on <automobile.LoadingAlertViewController: 0x7bfa55d0> whose view is not in the window...

SWIFT - Add image to alert view

swift,uiimage,uialertview,uialertcontroller
I have an alert view that pops up when the user press the add button. How do i add an image to the alert view? I added some code that i took reference from stack overflow. My save button is replaced with the image and the image appear to be...

How do I call a textfield from within an UIAlertController?

swift,uialertcontroller
So, I am making an app where when the "Start" button is pressed, an Alert via UIAlertController pops up and there are two textfields asking for the players' names, where I will move the player names to the game's screen (it's a Tic-Tac-Toe app) via override func prepareForSegue(segue: UIStoryboardSegue, sender:...

show UIAlertController outside of ViewController

ios,swift,uialertcontroller
I have trouble to display my UIAlertController because I'm trying to show it in a Class which is not an ViewController. I already tried adding it: var alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert) UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil) Which is not working... I didn't find any solution that...

Unwind Segue not being performed after shouldPerformSegueWithIdentifier UIAlertController

ios,iphone,swift,uiviewcontroller,uialertcontroller
I have an unwind segue from a UIViewController named DetailViewController to MainViewController defined as (within MainViewController): @IBAction func deleteItemUnwind(sender: UIStoryboardSegue) { let sourceViewController = sender.sourceViewController } In the DetailView, I have the button that should perform the segue connected to the scene exit with the name deleteItemUnwindSegue, and in DetailViewController...

UITextField in UIAlertController (border, backgroundColor)

ios,uitextfield,uialertcontroller
Here is a screenshot of a UIAlertController. I was just playing around custom fonts and textfield properties but I was unable to accomplish the following: clear background of the UITextField no ugly border (black box) as shown below As I dived more into the code and iOS runtime headers, I...

Swift Alert popup is appearing in simulator iphone4s(8.1), not iphone4s (7.1)

ios,xcode,swift,uialertcontroller
I have written code to display a simple alert popup when a button is clicked. When trying the app in simulator iPhone 4s (8.1), it's working as expected, but when trying in simulator iPhone 4s (7.1), the app keeps crashing. Here the code: @IBAction func buttonPressed(sender: UIButton) { let controller...

UIAlertController gone crazy, point to settings when it should cancel

xcode,swift,uialertcontroller
Anyone ever had an alert controller with a "cancel" action and just a return in the handler that does something? Mine goes to the app settings.... I have another alert controller in another viewcontroller that does that. But that shouldn't affect this one???? alertControl.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: { (alertAction)...

Cannot find an initializer for type 'UIAlertController' ERROR

ios,swift,uialertcontroller
I'm a bit new to this, please help! Heres the full error: Cannot find an initializer for type 'UIAlertController' that accepts an argument list of type '(title: String, message: (Int), preferredStyle: UIAlertControllerStyle)' Here's part of my code where the error occurs: import UIKit class ViewController: UIViewController, UITextFieldDelegate, UITextViewDelegate{ @IBOutlet weak...

Alert not working due to presentViewController

ios,uiviewcontroller,uialertcontroller
Seems that calling an Alert in my UIViewController causes ploblems with the presentViewController (...due to probably inadvertently trying to present the same view controller twice in quick succession...). What could I do against that issue (...see code below) ??? Error message : <MyApp.MyViewController: 0x67544325620> which is already presenting (null) The...

My UIAlertController keeps adding new buttons each time the alert is called, causing endless buttons

ios,swift,alert,uialertcontroller
I am adding alerts to prevent the user from overwriting previously used data, and I am using a UIAlertController as recommended in a different post. The involved code looks like this : var alert:UIAlertController = UIAlertController(title: "Are you sure?", message: "This will overwrite your information", preferredStyle: UIAlertControllerStyle.Alert) func showAlert() {...

Error executing the presentViewController command

ios,swift,uialertcontroller
I am sure I am just missing one step but I am at a loss to figure out what. I am trying to write a function I can call repeatedly to error check several fields. When a required field is empty, the function will be called to remind the user...

UIAlertController translucency glitch/bug

ios,cocoa-touch,uialertcontroller
When iOS presents an alert, the translucency is constant. When my app presents one, the alert is white at first, only for half a second, then it becomes translucent. It's a small issue, but it looks messy and alerts should be consistent everywhere I think. Anyways here is the code:...

Dismiss all UIAlertControllers currently presented

ios,swift,uiwindow,uialertcontroller
Is there a way to dismiss all UIAlertControllers that are currently presented? This is specifically because from anywhere and any state of my app, I need to get to a certain ViewController when a push notification is pressed. ...

Present UIAlertController from UIBarButtonItem

ios,iphone,uibarbuttonitem,uialertcontroller
I'm trying to show an UIAlertController from a UIBarButtonItem, just like in the web browser in the Facebook app when clicking the actions button. But haven't been successful. Been searching on Stack Overflow, Google, Github etc, but haven't found what I'm looking for. Here you can see how it looks...

Blocking a Loop Using UIAlertController

ios,objective-c,swift,uialertcontroller
is there a way for us to block a for loop? I have a loop where inside it, it ask user with a dialog box. I would like it to pause the loop after user press OK or Cancel. Is it possible? Because looping an alertController looks really ugly especialy...

iOS - UITableView inside an UIAlertController

ios,objective-c,uitableview,uialertcontroller
I know how to add any Custom UI inside UIAlertView by using accessoryView like UITableView but I am now curious that if we still have option to add Custom UI inside an UIAlertController, what I am wanting to have is a UITableViewController inside an UIAlertController with clear understanding.

iOS UIAlertController appears bigger than normal

ios,ios8,uialertcontroller
I bought an iOS application template, but I was wondering why the UIAlertController and the status bar do not appear like normal. It appears bigger than the default design. Why is this happening and how can I solve it?...

Change UIAlertView to UIAlertController of app to get updated to iOS 8

ios7,ios8,uialertview,deprecated,uialertcontroller
I have to update to iOS 8 some apps developed for iOS 7. After UIAlertView got deprecated on iOS 8. My question is: Is it neccesary to check the iOS version, and show a UIAlertController rather than a UIAlertView? Or can I leave the implementation of UIAlertView? Will iOS can...

Change UIActionSheet buttons background color and button font

ios8,uiactionsheet,uialertcontroller
I have a UIActionSheet in my application. I want to change the background color of actionsheet buttons and the font of the buttons. I made a search found below code: for (UIView *_currentView in actionSheet.subviews) { if ([_currentView isKindOfClass:[UIButton class]]) { //DO YOUR WORK } } but this code is...