UIAlertView delegate method is never called if `otherButtonTitles` parameter of the designated initialiser is nil
| Originator: | tony | ||
| Number: | rdar://15735553 | Date Originated: | 01-Jan-2014 05:43 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
When displaying a UIAlertView with a UITextField in iOS 7, the "alertViewShouldEnableFirstOtherButton:" method is never called if the `otherButtonTitles` parameter of the designated initialiser is nil, even if buttons are added via `addButtonWithTitle`.
Steps to Reproduce:
1. Open Xcode
2. Create a new "Single View Application"
3. Open "ViewController.m"
4. In the "viewDidLoad" method, instantiate a UIAlertView, and set its "alertViewStyle" to "UIAlertViewStylePlainTextInput" — specify 'nil' for the value of `otherButtonTitles`
5. Add a button to the alert view via `addButtonWithTitle:`
6. Implement the UIAlertViewDelegate "alertViewShouldEnableFirstOtherButton:" method in the view controller
7. Build and Run the Xcode project
8. Input some text into the UITextField
Expected Results:
The UIAlertViewDelegate "alertViewShouldEnableFirstOtherButton:" method should be called whenever a change is made to the UITextField.
Actual Results:
The UIAlertViewDelegate "alertViewShouldEnableFirstOtherButton:" method is never called if the `otherButtonTitles` parameter is nil on init.
Regression:
No, this didn't work properly under iOS 6 either.
Notes:
Below is an example of the code required to reproduce the bug.
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView {
NSLog(@"alertViewShouldEnableFirstOtherButton: was called!");
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"I’m an alert view!" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
[alertView addButtonWithTitle:@"Next"];
[[alertView textFieldAtIndex:0] setDelegate:self];
[alertView show];
}
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!