uialertcontroller

How to use UIAlertController to replace UIActionSheet?

牧云@^-^@ 提交于 2019-11-28 19:05:33
I am maintaining an old iOS project which based on SDK 6.0. A method on this project called -(void) showComboBox:(UIView*)view:withOptions:(NSDictionary*)options is used to show a combo box. To achieve the goal, it used UIActionSheet, which is deprecated on iOS8. My solution is like this: if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8) { UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction* item = [UIAlertAction actionWithTitle:@"item" style

UIPopover How do I make a popover with buttons like this?

喜夏-厌秋 提交于 2019-11-28 18:48:18
I'm wondering how I can create a popover with buttons like this. ANSWER: UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil delegate: self cancelButtonTitle: nil destructiveButtonTitle: nil otherButtonTitles: @"Take Photo", @"Choose Existing Photo", nil]; [actionSheet showFromRect: button.frame inView: button.superview animated: YES]; Somewhere else in your delegated object class... -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { // take photo... } else if (buttonIndex == 1) { // choose existing photo...

“Please wait” dialog in iOS8

我们两清 提交于 2019-11-28 17:58:58
I used to have a "Please wait" dialog in my app for long time. It was quite simple thing using UIActivityIndicatorView and adding it to UIAlertView . However iOS8 introduced UIAlertController . Is it possible to add anything to it to have similiar effect? Is there another way of doing such thing with iOS8? I have searched a lot of sites and still have no idea how it can be done with the new API. I would appreciate any answers - links to libs, tutorials etc., which could be helpful. Regards, Mateusz pheedsta Instead of using a UIAlertController, you can use a custom UIViewController that is

Check on UIAlertController TextField for enabling the button

点点圈 提交于 2019-11-28 17:52:49
I have an AlertController with a text field and two button: CANCEL and SAVE. This is the code: @IBAction func addTherapy(sender: AnyObject) { let addAlertView = UIAlertController(title: "New Prescription", message: "Insert a name for this prescription", preferredStyle: UIAlertControllerStyle.Alert) addAlertView.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) addAlertView.addAction(UIAlertAction(title: "Save", style: UIAlertActionStyle.Default, handler: nil)) addAlertView.addTextFieldWithConfigurationHandler({textField in textField.placeholder = "Title

iOS UIAlertController bold button changed in 8.3

被刻印的时光 ゝ 提交于 2019-11-28 17:44:59
UIAlertController with two buttons with styles set: UIAlertActionStyle.Cancel UIAlertActionStyle.Default in iOS 8.2, the Cancel button is non-bold and Default is bold. In iOS 8.3 they have switched round You can see it Apple's own apps e.g., Settings > Mail > Add Account > iCloud > enter invalid data, then it shows like this on 8.3: Unsupported Apple ID Learn More (bold) OK (non-bold) whereas it was the other way round for 8.2. Any workaround to make it like 8.2 again. Why has it changed? From iOS 9 you can set the preferredAction value to the action which you want the button title to be bold.

UIAlertController:supportedInterfaceOrientations was invoked recursively

百般思念 提交于 2019-11-28 17:24:07
问题 When two alert present one by one, i means one alert present and over them another alert presenting and app crashing. I have used UIAlertController to display alert. App crashing only in iOS 9 device. Please help me at this point. 回答1: This is a bug in iOS 9 that it failed to retrieve the supportedInterfaceOrientations for UIAlertController . And it seems it dropped to an infinite recursion loop in looking for the supportedInterfaceOrientations for UIAlertController (e.g., it tracks back to

Customize UIAlertController in iOS 8 to include standard elements like UITableView

馋奶兔 提交于 2019-11-28 17:14:28
问题 I am used to customize UIAlertViews through the [ alert setValue:someView forKey:@"accessoryView"] method. This creates customizable content for UIAlertViews with custom heights. However it only works on iOS7 and down. In iOS8 the UIAlertController have taken over, and I cannot customize it anymore, it will cut the height of the UIAlertView . Is it impossible because of misuse of the UIAlertController , or how am I supposed to do it? I am trying to incorporate a UITableView inside a

Access input from UIAlertController

时光毁灭记忆、已成空白 提交于 2019-11-28 16:58:10
I've got a UIAlertController which is prompted to the user when they choose "Enter Password" on the TouchID screen. How do I recover the user's input after presenting this on screen? let passwordPrompt = UIAlertController(title: "Enter Password", message: "You have selected to enter your passwod.", preferredStyle: UIAlertControllerStyle.Alert) passwordPrompt.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) passwordPrompt.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) passwordPrompt

iOS8统一的系统提示控件——UIAlertController

筅森魡賤 提交于 2019-11-28 16:56:12
iOS8统一的系统提示控件——UIAlertController 一、引言 相信在iOS开发中,大家对UIAlertView和UIActionSheet一定不陌生,这两个控件在UI设计中发挥了很大的作用。然而如果你用过,你会发现这两个控件的设计思路有些繁琐,通过创建设置代理来进行界面的交互,将代码逻辑分割了,并且很容易形成冗余代码。在iOS8之后,系统吸引了UIAlertController这个类,整理了UIAlertView和UIActionSheet这两个控件,在iOS中,如果你扔使用UIAlertView和UIActionSheet,系统只是会提示你使用新的方法,iOS9中,这两个类被完全弃用,但这并不说明旧的代码将不能使用,旧的代码依然可以工作很好,但是会存在隐患,UIAlertController,不仅系统推荐,使用更加方便,结构也更加合理,作为开发者,使用新的警示控件,我们何乐而不为呢。这里有旧的代码的使用方法: UIAlertView使用: http://my.oschina.net/u/2340880/blog/408873 。 UIActionSheet使用: http://my.oschina.net/u/2340880/blog/409907 。 二、UIAlertController的使用 从这个类的名字我们就可以看出,对于警示控件

UIAlertView automatic newline gone in iOS8?

我与影子孤独终老i 提交于 2019-11-28 12:56:07
It appears that UIAlertView is not compatible with iOS8. I've just discovered that all my multiline UIAlertViews become truncated one-liners in iOS8 (for the message). In iOS7 they are displayed correctly with multilines. iOS7: iOS8: [[[UIAlertView alloc] initWithTitle:@"Namn saknas" message:@"Du måste fylla i ditt namn för att kommentera" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show]; I'm aware of that UIAlertController should be used in iOS8 and later and that UIAlertView is deprecated as of iOS8. BUT shouldn't still work as previously (i.e iOS7) in iOS8? If not, shouldn