uialertcontroller

Swift - AVAudioPlayer, sound doesn't play correctly

﹥>﹥吖頭↗ 提交于 2019-11-28 12:54:33
Because UILocalNotification is not being displayed while the application is in active stat, I'm trying to configure an UIAlertController and playing a little sound when it appears. I've no problem, in the AppDelegate , to handle the notification/create the alert. My problem concerns the sound. Indeed, it doesn't play correctly. Here is what I have so far : //... class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for

How can I change the height of UITextField in UIAlertController in Swift?

老子叫甜甜 提交于 2019-11-28 12:31:24
I have added a UITextField in a UIAlertController . I want to change the height of the text field. I have tried this way: let alertController = UIAlertController(title: "Comments", message: "Write your comments here", preferredStyle: UIAlertControllerStyle.alert) alertController.addTextField { (textField : UITextField) -> Void in var frame: CGRect = textField.frame frame.size.height = 100 textField.frame = frame textField.placeholder = "comment" print(textField.frame.size.height) } let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) { (result : UIAlertAction) ->

iOS-8 and later - UITableView inside an UIAlertController

不问归期 提交于 2019-11-28 10:33:24
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. Syed Ali Salman Courtesy of StackOverflow users I was able to do this task. Here is my code: UIViewController *controller = [[UIViewController alloc]init]; UITableView *alertTableView; CGRect rect; if (array.count < 4) { rect = CGRectMake(0, 0, 272, 100); [controller setPreferredContentSize:rect.size]; }

UIAlertView in iOS8 appearing off-center, mis-placed, only portion of the screen dimmed

人盡茶涼 提交于 2019-11-28 08:54:36
问题 I'm building an iPad app on iOS8, landscape, upgrading from iOS7. I've replaced UIAlertView (deprecated) with UIAlertController in a number of other places in my app which has fixed this issue. However, I also use a UIWebView which apparently shows its own UIAlertViews. When this happens I also get the same problem (see partial pic, cropped). The alert view is misplaced lower to the left and only the left 2/3 of the screen is dimmed, and worse, the right most portion that is not dimmed still

UIAlertController handle dismiss upon click outside (IPad)

怎甘沉沦 提交于 2019-11-28 06:49:04
Previous to iOS8 we used the UIActionSheet for showing alert and now we need to use the UIAlertController. When we used the UIActionSheet we could easily handle situations where the user clicked outside the pop up (which means he want to cancel the operation) by comparing the clickedButtonAtIndex to the cancelButtonIndex - if the user indeed pressed outside the popup we got the cancel button index in this function. How can we handle these situations with the new UIAlertController? I tried to use the "completion" block but it doesn't have any context. Is there an easy way to handle this? (other

UIAlertController is moved to buggy position at top of screen when it calls `presentViewController:`

可紊 提交于 2019-11-28 05:44:56
Presenting a view from a UIAlertController moves the alert to a buggy position at the top-left corner of the screen. iOS 8.1, device and simulator. We have noticed this in an app when we attempt to present a view from the current "top-most" view. If a UIAlertController happens to be the top-most view we get this behavior. We have changed our code to simply ignore UIAlertControllers, but I'm posting this in case others hit the same issue (as I couldn't find anything). We have isolated this to a simple test project, full code at the bottom of this question. Implement viewDidAppear: on the View

How to display activity indicator in center of UIAlertController?

瘦欲@ 提交于 2019-11-28 05:24:44
I currently have a UIAlertController being displayed on the screen. The view of the alert should only display 2 elements, a title and a UIActivityIndicatorView in the center of the alert. Below is the function that displays the alert and its elements. func displaySignUpPendingAlert() -> UIAlertController { //Create the UIAlertController let pending = UIAlertController(title: "Creating New User", message: nil, preferredStyle: .Alert) //Create the activity indicator to display in it. let indicator = UIActivityIndicatorView(frame: CGRectMake(pending.view.frame.width / 2.0, pending.view.frame

Add image to UIAlertController [closed]

偶尔善良 提交于 2019-11-28 05:05:28
问题 I want to add an image to UIAlertController. Image does not need to be on a button, just presented in the middle of the controller. The code I have is below but crashes with message "unrecognised selector sent to instance". func showAlert () { let alert = UIAlertController(title: "Title of Alert", message: "none", preferredStyle:UIAlertControllerStyle.ActionSheet) // add an image let image = UIImage(named: "example") var imageView = UIImageView(image: image) imageView.frame = CGRectMake(0, 0,

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

放肆的年华 提交于 2019-11-28 04:36:22
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 (null) Ideally, I would ideally like to handle this in my UIAlertController extension method. class func simpleAlertWithMessage(message: String!) -> UIAlertController { let alertController = UIAlertController(title: nil, message: message, preferredStyle:

How to add TextField to UIAlertController in Swift

醉酒当歌 提交于 2019-11-28 04:15:48
I am trying to show a UIAlertController with a UITextView . When I add the line: //Add text field alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in } I get a Runtime error: fatal error: unexpectedly found nil while unwrapping an Optional value let alertController: UIAlertController = UIAlertController(title: "Find image", message: "Search for image", preferredStyle: .Alert) //cancel button let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in //cancel code } alertController.addAction(cancelAction) //Create an optional