uialertview

How to add userInfo to a UIAlertView?

时光毁灭记忆、已成空白 提交于 2019-11-27 07:08:10
I would like to know how to add a userInfo object, or any NSDictionary, to a UIAlertView? Thank you. If you are on > iOS 4.0 (for blocks) and you only want one or two buttons, you could use this category I made: https://github.com/rsaunders100/UIAlertView-Blocks It bypasses the need to add user info since you put your click handeling function straight into the alert. e.g. #import UIAlertView+Blocks.h ... ... NSString* myUserInfo = @"example"; [UIAlertView displayAlertWithTitle:@"Example Alert View With Blocks" message:nil leftButtonTitle:@"Ok" leftButtonAction:^{ NSLog(@"%@", myUserInfo); }

Unable to add UITextField to UIAlertView on iOS7…works in iOS 6

别来无恙 提交于 2019-11-27 06:43:16
The code below works on iOS6 (and before) but the UITextField does not display in iOS7...any ideas on how to get a UITextField to display in an UIAlterView in iOS7? UIAlertView* dialog = [[UIAlertView alloc] init]; [dialog setDelegate:self]; [dialog setTitle:@"Enter ESC Score"]; [dialog setMessage:@" "]; [dialog addButtonWithTitle:@"Cancel"]; [dialog addButtonWithTitle:@"OK"]; dialog.tag = 5; nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)]; [nameField setKeyboardType:UIKeyboardTypeNumberPad]; [nameField becomeFirstResponder]; [nameField setBackgroundColor:

iphone UIAlertView Modal

跟風遠走 提交于 2019-11-27 06:04:42
问题 Is it possible to present a UIAlertView and not continue executing the rest of the code in that method until the user responds to the alert? Thanks in advance. 回答1: I guess stopping the code you meant was to stop the device to run the next code you have written after the alertview For that just remove your code after your alertview and put that code in the alertview delegate -(void) yourFunction { //Some code UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Your Message"

iPhone: detecting if a UIAlert/UIActionSheet are open

五迷三道 提交于 2019-11-27 06:04:32
问题 In my iOS application, I have a timer firing up, and when it fires, I need to be able to detect whether there's an Alert (UIAlertView) or an Action Sheet (UIActionSheet) open. One way would be to modify the code presenting the alerts/actionsheets - but unfortunately this is not an option in my case. So, the question is - is there a way of knowing/detecting whether an alert or action sheet have been opened? Is there any notifications sent upon opening, or any traversal of the view hierarchy to

How can I show alertview with activity indicator?

烂漫一生 提交于 2019-11-27 04:47:36
I want to show alertview with message: "Loading data" and spinning activity indicator. How can I do this? Sat you can add a label and activityindicator as subviews of your alert view. you have to do some thing like this myAlertView = [[UIAlertView alloc] initWithTitle:@"Loading" message:@"\n\n" delegate:self cancelButtonTitle:@"" otherButtonTitles:@"OK", nil]; UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; loading.frame=CGRectMake(150, 150, 16, 16); [myAlertView addSubview:loading]; [myAlertView show]; .

Is it possible to NOT dismiss a UIAlertView

时光怂恿深爱的人放手 提交于 2019-11-27 04:45:48
The UIAlertviewDelegate protocol has several optional methods including: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; This would seem to suggest that not all button clicks actually dismiss the alert view. However I see no way of configuring the alert view to NOT automatically dismiss with any button press. Do I have to create a subclass to accomplish this? Why would the UIAlertViewDelegate Protocol have: - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; - (void)alertView:(UIAlertView *)alertView

iOS How to dismiss UIAlertView with one tap anywhere?

瘦欲@ 提交于 2019-11-27 04:39:10
问题 I want to dismiss UIAlertView anywhere outside it with one tap. I want to show a UIAlertView without any button. I have standard UIAlertView codes here, but I need input how to dismiss it, if it is possible. With UITouch? With UITapGestureRecognizer? Thank you. EDIT: in viewDidLoad alertview initialization here with name "alert" if (alert) { emptyview = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,480)]; emptyview.backgroundColor = [UIColor clearColor]; [self.view addSubview:emptyview];

Concurrent UIAlertControllers

社会主义新天地 提交于 2019-11-27 04:33:52
问题 I'm porting my app to iOS 8.0 and notice that UIAlertView is deprecated. So I've changed things to use a UIAlertController. Which works in most circumstances. Except, when my app opens, it does several checks to report various states back to the user... E.g... "Warning, you haven't set X up and need to do Y before completing projects" and "Warning, you are using a beta version and do not rely on results" etc...(these are just examples!) Under the UIAlertView, I would (say) get two alert boxes

How to dismiss UIAlertController when tap outside the UIAlertController?

爷,独闯天下 提交于 2019-11-27 04:28:01
How to dismiss UIAlertController when tap outside the UIAlertController ? I can add a UIAlertAction of style UIAlertActionStyleCancel to dismiss the UIAlertController . But I want to add the function that when user tap outside the UIAlertController the UIAlertController will dismiss. How to do that? Thank you. Vivek Yadav Add a separate cancel action with style UIAlertActionStyleCancel . So that when user taps outside, you would get the callback. Obj-c UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert Title" message:@"A Message" preferredStyle

Where Does A UIAlertView Live While Not Dismissed

99封情书 提交于 2019-11-27 04:27:02
Does anyone know in whose subview an active UIAlertView is located or how to find the thread in which it is running? If you dump the contents of the windows property and all subviews of all views you can see that the UIAlertView is in a separate window that overlays the main window. Here I have a navbar with a viewcontroller and a tableview (I removed its subviews since they're not relevent). <UIWindow: 0x411fd50; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x4120af0>> : <UILayoutContainerView: 0x4123310; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer