uialertview

Keep UIAlertView displayed

别说谁变了你拦得住时间么 提交于 2019-12-19 10:34:12
问题 I have a UIAlertView with a textField on it and two buttons: Save & Cancel. When the Save button is tapped I am checking if the text field isn't empty and after if it is I simply want to change the textFields placeholder to: @"enter a name please" and KEEP the alert view on screen. However it is automatically dismissed. How do I override that? 回答1: Add a target to the textfield in a subclassed alertView. You can subclass the alertView and not dismiss as described in this post [[alertView

Add UIDatePicker to UIAlertView

混江龙づ霸主 提交于 2019-12-19 07:09:08
问题 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

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

时间秒杀一切 提交于 2019-12-19 05:58:21
问题 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? 回答1: 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

create alert function in all view controllers - swift

半城伤御伤魂 提交于 2019-12-19 04:23:32
问题 I'm trying to declare a function for showing alerts in my app. To avoid repeating work, i'm trying to use same function for all my app. I tried to do that by creating a class with function showNotification. but when i create an object of that class and call the method, nothing happens. How can i do that? class SharedPropertiesAndMetods : UIViewController { func showNotification(title: String, message: String) { let alertController = UIAlertController(title: title, message: message,

Handling Push Notifications when App is NOT running (i.e Totally Killed)

若如初见. 提交于 2019-12-19 04:14:31
问题 I'm able to send push notifications to my IOS device. But when I click on that notification it just opens the app. No message is shown inside the app. Code used by me: if (application.applicationState == UIApplicationStateActive) { NSString *cancelTitle = @"Close"; NSString *showTitle = @"Show"; NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title" message:message delegate:self cancelButtonTitle

Rotating a UIAlertView

旧时模样 提交于 2019-12-19 02:27:21
问题 I've created a custom UIAlertView (by subclassing it and messing around with its show function) that has some custom subviews and is of non-standard size. It works ok when I create and display it, however, when the device is rotated, the alert rotates and then returns to its default size. Any ideas what functions to override - or should I tweak the UIViewController? thanks, Peter 回答1: Not sure if force rotating the UIAlertView fits the Apple GUI guidelines, but you can rotate it by defining

Why doesn't dismissWithClickedButtonIndex ever call clickedButtonAtIndex?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 19:02:57
问题 http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html I'm using that code to get my iPhone app to display an alertView with an included UITextField and matching CANCEL and OK buttons. The user can enter text, hit CANCEL or OK... and I see the text the user entered... using my code inside the clickedButtonAtIndex method. It all works except for 1 thing: Instead of OK, the user might hit DONE on the keyboard. I'm using dismissWithClickedButtonIndex to simulate an OK click...

Make button it UIAlertView perform Segue

谁说我不能喝 提交于 2019-12-18 13:17:02
问题 I have created a UIAlertView for an action which gives me 2 options. I want the user to be able to click on a button and have it perform a Segue. Here's the code I have so far: - (IBAction)switchView:(id)sender { UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Please Note" message:@"Hello this is my message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Option 1", @"Option 2", nil]; [myAlert show]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:

Make UIAlertView Button trigger function On Press

与世无争的帅哥 提交于 2019-12-18 10:55:44
问题 Currently I am using the following code to present a UIAlertView: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Today's Entry Complete" message:@"Press OK to submit your data!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; How do I get it so that when 'OK" is pressed, it triggers a function, say -(void)submitData 回答1: NOTE: Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and

View on top of everything: UIWindow subview VS UIViewController subview

时光怂恿深爱的人放手 提交于 2019-12-18 10:27:37
问题 In order to make a UIView on top of all views like the behavior of UIAlertView , the best way I see is by putting it in the app window, which is by adding the view to: [[[UIApplication sharedApplication] delegate] window] However, the downside I found is that it doesn't automatically take in rotation. In order for it to take in rotation, the best way to do is by adding the view on current AppDelegate window.navigationController / rootViewController , however, by doing this it will no longer