uialertcontroller

UIAlertController 'UIAlertAction' tag/userdata or anything in Swift

给你一囗甜甜゛ 提交于 2019-12-10 03:45:31
问题 in my iOS actionsheet, I am showing Names from the JSON dictionary: [ { "Name": "Doctor for Disease AAA", "Doctor_id": "21" }, { "Name": "Doctor for Disease BBB", "Doctor_id": "22" }, { "Name": "Doctor for Disease AAA", "Doctor_id": "25" } ] So, on button click delegate, I can get the button index and can fetch the corresponding 'Name' and 'Doctor_id'. This is working fine. But now it seems like 'UIActionSheet' is deprecated, and I have to use 'UIAlertController'. As I have a large data, I am

Select text in UIAlertController's text field

这一生的挚爱 提交于 2019-12-10 03:34:38
问题 I need the text of the text field to be selected right after the UIAlertController is presented. However, the way I select text in a standard UITextField doesn't work here. This is what I tried, but I can't seem to get it work. let ac = UIAlertController(title: "Rename", message: nil, preferredStyle: .Alert) ac.addTextFieldWithConfigurationHandler({ [] (textField: UITextField) in textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField

Warning: Presenting view controllers on detached view controllers is discouraged

妖精的绣舞 提交于 2019-12-09 19:23:13
问题 My situation with this is different than every other example I have been able to find on here. I have a tab based app. On one of the tabs a user is able to press a button that downloads several files from a web server all at once. I make use of NSOperation to perform each of these downloads so that I can utilize the built in dependencies. The downloads are all occurring on a background thread so the app remains responsive. When the final download is complete I put an alertController on screen

How to rotate UIAlertController in Swift

故事扮演 提交于 2019-12-09 17:04:50
问题 I have a working UIAlertController , but I want to rotate the alert.view by 90 degrees left. How can I do it? My code is here below: let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "Okay", style: .Default){(action)->() in }) presentViewController(alert, animated: true) {} I tried to add: alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) but it doesn't work. Thank you ! 回答1: With this code: let

Custom Action controller, Swift

独自空忆成欢 提交于 2019-12-09 06:04:37
问题 Does anyone know how I can code up this custom alert controller (The top area especially) - currently found on the Apple music App. Maybe there is a known library that can do it. I am aware this is how you an action controller is coded? let alertController = UIAlertController(title: nil, message: "Top Message Here", preferredStyle: .ActionSheet) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in // Drop View Pop up } alertController.addAction(cancelAction) let

change UIAlertcontroller background Color

痞子三分冷 提交于 2019-12-09 04:41:06
问题 Ok so I have this alert that I am using and I want the background of it to be black not grey like it is. I have managed to change the colour of the text for the title and the message but not the background colour. Well to the desired colour I want. I have changed it to green blue and white, but not black. When I try to change it to black it turns grey. Any suggestions will help and be appreciated. I tried this here How to change the background color of the UIAlertController? and that is how I

How to show an alert from another class in Swift?

烂漫一生 提交于 2019-12-09 04:08:44
问题 I have a main class, AddFriendsController , that runs the following line of code: ErrorReporting.showMessage("Error", msg: "Could not add student to storage.") I then have this ErrorReporting.swift file: import Foundation class ErrorReporting { func showMessage(title: String, msg: String) { let alert = UIAlertController(title: title, message: msg, preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil)) self

'UIAlertView' was deprecated in iOS 9.0. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

感情迁移 提交于 2019-12-08 22:56:46
问题 I have see more so answers , but nothing helped.Here is my older alert and action for that override func viewWillAppear(animated: Bool) { if Reachability.isConnectedToNetwork() == true { print("internet connection ok") } else { print("internet not ok") let alertView: UIAlertView = UIAlertView(title: "Alert ", message: "connect to internet", delegate: self, cancelButtonTitle: "settings", otherButtonTitles: "cancel") alertView.show() return } } func alertView(alertView: UIAlertView,

show alertController from a custom class

若如初见. 提交于 2019-12-08 07:16:23
问题 I'm trying to show an AlertController from a class that I've made. Since AlertController is a subclass of UIResponder I'm using the following line of code that Xcode is suggesting me superclass?.presentViewController(alertController, animated: true, completion: nil) But I cannot compile because AnyClass? does not have any member presentViewController. My class is a subclass of NSObject. Any other solution? Thanks 回答1: Well you just need to find the topmost view controller and present the

iOS AlertView App Extension

流过昼夜 提交于 2019-12-08 03:56:31
问题 I'm working in a custom keyboard (iOS App Extension) . I have a UICollectionView in my Keyboard Layout , so when one item is selected I want to show a message ( UIAlerView for example). Here is my code: - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ ... UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"My Title" message:@"Enter User Credentials" preferredStyle:UIAlertControllerStyleAlert]; [self