uialertview

Two Alert Views in One View Controller - buttonIndex Response

左心房为你撑大大i 提交于 2019-12-01 05:36:08
I am trying to perform the smile task of having two alerts in a single View Controller. The code below works fine, but how would I make another instance of it elsewhere in the View Controller. I am concerned that if I duplicated the code, my buttonIndex would not know which alert it is responding to. Any ideas? Thanks! -(void)alertChoice { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Confirm", nil]; [alert show]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger

Disappearing UILocation alerts in XCode 4.2 with ARC iPhone

China☆狼群 提交于 2019-12-01 05:16:51
问题 The alerts appear for a split-second or did not show when application launches in project with ARC (without using ARC all it's OK). (I add CoreLocation framework and I import it to project). My code: #import <CoreLocation/CoreLocation.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ CLLocationCoordinate2D coordinate; CLLocationManager *locationManager = [[CLLocationManager alloc] init]; NSLog(@"jestem po okienku "); if

Add UIDatePicker to UIAlertView

谁说我不能喝 提交于 2019-12-01 04:36:05
I am trying to add a date picker to an alert view. I can add the animation to the screen based on a button click and I see a black box but no date picker. Here is what I have so far.... - (IBAction)showDatePicker { CGRect frame = CGRectMake(200, self.view.frame.size.height, self.view.frame.size.width, 0); //CGRectMake(225, 145, 260, 125); UIPickerView *datePicker = [[UIPickerView alloc] initWithFrame:frame]; UIAlertView *showDateAlert = [[UIAlertView alloc] initWithTitle:@"Enter the Code Date" message:@"Sample message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Update", nil]

UIAlertView changes to landscape when App is locked in portrait only in iOS8

点点圈 提交于 2019-12-01 03:55:41
I have an app and its orientation is locked as portrait mode, but when I have a UIAlertView and turn the iPhone to landscape, the alert changes the orientation and crops the alert's overlay. Only in iOS8. Anyone had this error? Yes I did get this issue. I have developed my code in iOS7 but had to do compatible with iOS 8 also. So I came across This link . I got my solution as follows: When you are working with iOS7 UIAlertView works fine but if you are working with iOS8 you have to use UIAlertController. Use this kind of code: if(SYSTEM_VERSION_LESS_THAN(@"8.0")) { alert = [[UIAlertView alloc]

Change button title color in UIAlertView

扶醉桌前 提交于 2019-12-01 03:33:16
How can I change the color of the UIAlertView button title. I want title Ok in red color. Actually, you can change the tint color of the view of the UIAlertController in iOS8. UIAlertController *alertController = .... [alertController.view setTintColor:[UIColor greenColor]]; for Swift 3, use: alertController.view.tintColor = UIColor.red AFTER you present your alert controller The Travis Weerts answer should work if you are using a UIAlertController . For those using UIAlertView , you can use the UIView appearance settings. You can aim the alerts component this way on iOS < 9 : [[UIView

prevent UIAlertView from dismissing

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 03:23:38
As a form of validation, is there any way to prevent an alert view from dismissing when pressing an "OK" button? Scenario: I have 2 text fields in the alertview for username/password. If both are empty and the user presses "OK", I do not want the alert to be dismissed. Joony iOS 5 introduces a new property to UIAlertView to handle exactly this problem. alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput; Apple documentation on UIAlertView. Add the new UIAlertViewDelegate method to handle the enabling/disabling of the button. - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *

Display Alert Message from viewDidLoad

青春壹個敷衍的年華 提交于 2019-12-01 02:47:51
I want to display a alert message from viewDidLoad() method of ViewController.m instead from viewDidAppear() method. Here is my code : - (void)viewDidLoad { [super viewDidLoad]; //A SIMPLE ALERT DIALOG UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"My Title" message:@"Enter User Credentials" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { NSLog(@"Cancel action"); }]; UIAlertAction *okAction =

UIAlertView: UIAlertViewStyleSecureTextInput: Numeric keyboard

和自甴很熟 提交于 2019-12-01 02:29:44
I'm currently using this UIAlertView to do a login popup, UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Restricted" message:@"Please Enter Code to Enable Fields" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Login" , nil]; alert.alertViewStyle = UIAlertViewStyleSecureTextInput; [alert show]; However I would like the text input to be a numeric keyboard instead of the regular keyboard Is there a easy way to do this, or do I have to look into creating a custom UIAleartView Abhishek Singh You can try this to change the keyboard type of the UIAlertView 's field: [[alert

Forcing UIAlertView into landscape mode

左心房为你撑大大i 提交于 2019-12-01 02:24:12
I need to display a UIAlertView in landscape mode. I tried the obvious, setting the transform in the willPresentAlertView: delegate method to no avail: -(void) willPresentAlertView:(UIAlertView *)alertView { alertView.transform = CGAffineTransformMakeRotation(M_PI_2); } Any suggestions on how to fix this? Have you tried in the didPresentAlertView ? - (void)didPresentAlertView:(UIAlertView *)alertView { // UIAlertView in landscape mode [UIView beginAnimations:@"" context:nil]; [UIView setAnimationDuration:0.1]; alertView.transform = CGAffineTransformRotate(alertView.transform, 3.14159/2);

Change font size for UIAlertView in iOS7

被刻印的时光 ゝ 提交于 2019-12-01 01:55:14
I want to change the font size of message text and title text in alertView. There is no documentation in apple site that speaks about this but apple says "The UIAlertView class is intended to be used as-is" in their subclassing notes. Please refer the below link. https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html I am really confused if changing an alert view text size is something to be avoided or can it be changed? Can anyone advise me on What is the best practice for this? If the text size can be changed, can you also provide