In iOS 8 and above UIAlertView is deprecated so you can’t use UIAlertView in your beloved application. Apple has recently introduced new UIAlertController instead of UIAlertView. In this blog we would like to share how you can use UIAlertView both (with and without buttons) for iOS8 and above.
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Rate AppRateDemoProject"
message:@"If you enjoy AppRateDemoProject would you mind taking a moment to rate it?"
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
To add button in UIAlertController enter the following code.
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Rate AppRateDemoProject"
message:@"If you enjoy AppRateDemoProject would you mind taking a moment to rate it?"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* Btn1 = [UIAlertAction
actionWithTitle:@"Remind Me Later"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* Btn2 = [UIAlertAction
actionWithTitle:@"Rate It now"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancelBtn= [UIAlertAction
actionWithTitle:@"No Thanks"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:Btn1];
[alert addAction:Btn2];
[alert addAction:cancelBtn];
[self presentViewController:alert animated:YES completion:nil];
If you have any further doubts, drop us an email at info@infigic.com and we’ll get back to you with the best possible solution. Infigic is a Mobile Application Development Company and we are always there to solve your queries.
Comments
Post a Comment