Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UIAlertController for iOS 8 and higher instead of deprecated UIAlertView #340

Closed
funnel20 opened this issue Apr 4, 2016 · 0 comments

Comments

@funnel20
Copy link
Contributor

funnel20 commented Apr 4, 2016

UIAlertView is deprecated in iOS 8.0.
There is still one entry in IASKAppSettingsViewController (and 1 in the demo's MainViewController).
Obviously UIAlertView should stay in to support iOS 7 and lower.
However, it would be appropriate to use UIAlertController when available (for iOS 8 and higher).

Here is my suggestion to change the ELSE condition of the MailComposer check in 'didSelectRowAtIndexPath:':

Existing code:

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:NSLocalizedString(@"Mail not configured", @"InAppSettingsKit")
                      message:NSLocalizedString(@"This device is not configured for sending Email. Please configure the Mail settings in the Settings app.", @"InAppSettingsKit")
                      delegate: nil
                      cancelButtonTitle:NSLocalizedString(@"OK", @"InAppSettingsKit")
                      otherButtonTitles:nil];
[alert show];

New code:

if ([UIAlertController class]) {
    // >= iOS 8
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Mail not configured", @"InAppSettingsKit")
                                                                   message:NSLocalizedString(@"This device is not configured for sending Email. Please configure the Mail settings in the Settings app.", @"InAppSettingsKit")
                                                            preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"InAppSettingsKit")
                                                           style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * action) {
                                                             // Do nothing
                                                         }];

    [alert addAction:cancelAction];

    [self presentViewController:alert
                       animated:YES
                     completion:nil];
}
else {
    // < iOS 8
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Mail not configured", @"InAppSettingsKit")
                                                    message:NSLocalizedString(@"This device is not configured for sending Email. Please configure the Mail settings in the Settings app.", @"InAppSettingsKit")
                                                   delegate:nil
                                          cancelButtonTitle:NSLocalizedString(@"OK", @"InAppSettingsKit")
                                          otherButtonTitles:nil];
    [alert show];
}
futuretap added a commit that referenced this issue Sep 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants