uialertview

How to add an action to a UIAlertView button using Swift iOS

杀马特。学长 韩版系。学妹 提交于 2019-11-28 16:59:58
I want to add another button other than the "OK" button which should just dismiss the alert. I want the other button to call a certain function. var logInErrorAlert: UIAlertView = UIAlertView() logInErrorAlert.title = "Ooops" logInErrorAlert.message = "Unable to log in." logInErrorAlert.addButtonWithTitle("Ok") How do I add another button to this alert, and then allow it to call a function once clicks so lets say we want the new button to call: retry() Jake The Swifty way is to use the new UIAlertController and closures: // Create the alert controller let alertController = UIAlertController

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的使用 从这个类的名字我们就可以看出,对于警示控件

How to make a multiple line, left-aligned UIAlertView?

别来无恙 提交于 2019-11-28 16:51:37
问题 I am interested in making a left-aligned UIAlertView with several lines like a bulletin list that would look like the following: line 1 line 2 line 3 Here's what I have so far: alert = [[UIAlertView alloc] initWithTitle: @"How to use buttons" message: @"line 1. line 2, line 3 " delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil]; I also want to change the color of the alert view to red. 回答1: Bullets are represented by the unicode code 0x2022. I got it to work like this using "\n"

How to add a TextField to UIAlertView in Swift

霸气de小男生 提交于 2019-11-28 16:42:08
问题 I have this code, but I dont know how to show a textfield inside the UIAlertView. var altMessage = UIAlertController(title: "Warning", message: "This is Alert Message", preferredStyle: UIAlertControllerStyle.Alert) altMessage.addAction(UIAlertAction(title: "Done", style: UIAlertActionStyle.Default, handler: nil)) self.presentViewController(altMessage, animated: true, completion: nil) I have this code for textfield , how can I show this in UIAlerView var my:UITextField = UITextField(frame:

iOS - Push notification alert is not shown when the app is running

99封情书 提交于 2019-11-28 15:54:12
I've integrated push notifications in my app. Users will receive push notification to join a group. When the user clicks Join , I've to handle something in the code. And so I'm implementing: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo This is working fine when the app is not running. When the app is running, I don't see any UIAlertView . How can make my app show the push notification alert so that user can still decide whether to join or not? Jakob W I used code like this in my application delegate to mimic the notification alert when

Adding a simple UIAlertView

纵饮孤独 提交于 2019-11-28 15:45:53
What is some starter code I could use to make a simple UIAlertView with one "OK" button on it? sudo rm -rf When you want the alert to show, do this: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ROFL" message:@"Dee dee doo doo." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; // If you're not using ARC, you will need to release the alert view. // [alert release]; If you want to do something when the button is clicked, implement this delegate method: - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { // the user

UIAlertView crashes when added to app

 ̄綄美尐妖づ 提交于 2019-11-28 14:32:39
I am trying to impliment a basic UIAlertView into my app (I am using storyboard). But when I run my app, it goes to the debugger screen after stalling at the app's loading screen. my .h: #import <UIKit/UIKit.h> @interface MindTripAnim :UIViewController { IBOutlet UIImageView *animation; } - (IBAction)showMessage:(id)sender; @end and my .m: #import "MindTripAnim.h" @interface MindTripAnim () @end @implementation MindTripAnim - (void)viewDidLoad { animation.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"trips1.png"], [UIImage imageNamed:@"trips2.png"], [UIImage imageNamed:@

Dismiss UIAlertView after 5 Seconds Swift

我的梦境 提交于 2019-11-28 14:30:28
问题 I've created a UIAlertView that contains a UIActivityIndicator. Everything works great, but I'd also like the UIAlertView to disappear after 5 seconds. How can I Dismiss my UIAlertView after 5 seconds? var alert: UIAlertView = UIAlertView(title: "Loading", message: "Please wait...", delegate: nil, cancelButtonTitle: "Cancel"); var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(50, 10, 37, 37)) as UIActivityIndicatorView loadingIndicator.center = self

iOS 7 UIDatePicker in UIAlertView customisation

筅森魡賤 提交于 2019-11-28 14:09:08
Guys I was adding UIDatePicker to UIAlertView like this It was fine with iOS 6 and below now in iOS 7 it comes like this Any ideas why this happens? Is there a better way of doing this?.Any help is appreciated. This is my component to support addSubview in AlertView. CXAlertView - Custom alert-view which allow you to add view as main content. You can change accessoryView to any own customContentView in a standard alert view in iOS7 [alertView setValue:customContentView forKey:@"accessoryView"]; Note that you must call this before [alertView show] . Simplest illustrating example: UIAlertView

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