Skip to content

Instantly share code, notes, and snippets.

@Eridana
Created January 17, 2015 14:42
Show Gist options
  • Select an option

  • Save Eridana/6b4ee65c0e2bb7c40b8d to your computer and use it in GitHub Desktop.

Select an option

Save Eridana/6b4ee65c0e2bb7c40b8d to your computer and use it in GitHub Desktop.
UIAlertView and UIAlertController
if ( NSClassFromString(@"UIAlertController") != nil ) {
//make and use a UIAlertController
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"Вы не авторизованы"
message:@"Пожалуйста введите логин и пароль"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
}];
/*
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel action");
}];
*/
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
else {
//make and use a UIAlertView
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Вы не авторизованы"
message:@"Пожалуйста введите логин и пароль"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
}
// More this - http://useyourloaf.com/blog/2014/09/05/uialertcontroller-changes-in-ios-8.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment