uialertcontroller

Make UITabBar wait for user input before switching tab

。_饼干妹妹 提交于 2019-12-11 05:45:48
问题 I have a UITabBar with 5 tabs. When the middle tab is selected I want a UIAlertController Action Sheet to pop up, await user action and then load the new view once the user has selected from the Sheet since I need the data from the Sheet to load the view correctly. I currently have this code: extension CustomTabBarController: UITabBarControllerDelegate { func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool { guard let index =

UIAlertController + addTextField orientation issue from iOS10 on iPad

*爱你&永不变心* 提交于 2019-12-11 05:14:01
问题 When I use UIAlertController with addTextField on iPad, the keyboard doesn't rotate properly from iOS10. It was working fine with iOS9, does anybody know the way to fix it? UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *done = [UIAlertAction actionWithTitle:NSLocalizedString(@"Done", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { UITextField *textField = alert

UIAlertController utility class fails to call UITextField delegate or target but works in UIViewController

我怕爱的太早我们不能终老 提交于 2019-12-11 04:23:57
问题 I encountered a strange issue and maybe it is only a lack of knowledge about Swift 3.0 / iOS 10 so hopefully you can guide me into the right direction or explain to me what I'm doing wrong. HOW IT CURRENTLY WORKS I am trying to create a UIAlertController with style .alert so I can get a user text input for my app. My requirements are that the text must not be empty and if there was a text there before, it must be different. I can use the following code to achieve what I want: //This function

How to insert UILabel after UITextField in UIAlertController

别等时光非礼了梦想. 提交于 2019-12-11 03:17:23
问题 I have a UIAlertController of .alert style with message text. I have inserted a UITextFiled in it with addTextField(.... and now I want a string of text below it. I assume I need a UILabel but how do I insert it? 回答1: A UIAlertController sub-classes from UIViewController . Because of this, a UIAlertController contains a view which can be modified. So, to add a label to the alert, you could do this: let label = UILabel(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) label.text = "Text" alert

iOS dismiss UIAlertController in response to event

社会主义新天地 提交于 2019-12-11 02:18:17
问题 I have a situation where I want to present a UIAlertController in order to wait for an event (asynchronous request for data from third party) to finish before showing my main ViewController to the user to interact with. Once the asynchronous code finishes, then I want to dismiss the UIAlertController . I know that normally UIAlertControllers are setup with a button to dismiss it, which is input from the user. I am wondering if what I want to do (dismiss with an event instead of user input) is

ios 10+, Swift 3+ - Cannot dismiss UIAlertController from Singleton instance

回眸只為那壹抹淺笑 提交于 2019-12-11 00:15:08
问题 I have created an overlay to run while I run an async data grab to the server so that users won't continue pressing buttons in the UI until the data grab is done. I have put the function into a global singleton class and I call it while passing in a bool to say whether or not I want to show or hide. I can get it to show but I cannot get it to hide. Here is the code: class DataModel { static let sharedInstance = DataModel() func accessNetworkData(vc: UIViewController, params: [String:Any],

How to remove delay from UIAlertController?

自闭症网瘾萝莉.ら 提交于 2019-12-10 23:47:20
问题 After I tap table cells, I am getting a delay of 4 to 5 seconds for the alert view to display. Below is the code func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){ let cell = tableView.cellForRow(at: indexPath)! let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .alert) let ok = UIAlertAction(title: "Ok", style: .default, handler: { (action) -> Void in let cell = tableView.cellForRow(at: indexPath)! }) let cancel = UIAlertAction(title

CLLocation Prompt shows and disappears in one moment

纵然是瞬间 提交于 2019-12-10 17:56:04
问题 In my app I try to get longitude and latitude from GPS. To do that I have to ask user about permission to access to his location. Before I do that I add to Info.plist this two rulees: Privacy - Location When In Use Usage Description and Privacy - Location Always Usage Description , then in AppDelegate I ask about permission doing it (SWIFT 3.0): if CLLocationManager.locationServicesEnabled() == true { let localisationManager = CLLocationManager() localisationManager

EXC_BAD_ACCESS on UIAlertController code = 1

五迷三道 提交于 2019-12-10 17:54:18
问题 I have a view controller from where I am launching an UIAlertController on click of a Button. Below is my code: - (IBAction)playOnlineURL:(UIButton *)sender { [self launchPlayURLAlert]; } - (void) launchPlayURLAlert{ NSString *defaultURLString = @“MY URL”; UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"Play Online URL" message: @"Enter the URL" preferredStyle:UIAlertControllerStyleAlert]; [alertController addTextFieldWithConfigurationHandler:^(UITextField

How to add UIDatePicker in UIAlertController in iOS8?

风流意气都作罢 提交于 2019-12-10 16:47:39
问题 I am working on a project which I had already released with iOS-7. But now as the action sheet is making problem so I am now implementing UIAlertController. Following is the code which I am using for showing UIAlertController with UIPicker. alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil]; [alertController