Surfer
Surfer

Reputation: 1380

UIAlertView and UIActionSheet not displaying properly in iOS 8

UIAlertView and UIActionSheet not displaying properly in iOS 8, its hiding the view controller, also In alert view title is not displaying. I am running the app from Xcode 5.1.1.

Action Sheet

Alert View

Upvotes: 5

Views: 3117

Answers (3)

Nookaraju
Nookaraju

Reputation: 1668

Did you added any category for ViewController in your application. like below shown

@implementation UIViewController (CustomeAction)
- (void)setTitle:(NSString *)title{
// YOU CODE///
}
@end

This may the issue. I have solved by removing this category - (void)setTitle:(NSString *)title.

Note: From iOS 8, UIAlertViewController is inherited from UIViewController. If you use category method, it will be effect on UIAlertView & UIActionSheet titles.

You can refer apple docs at UIAlertController Class Reference

Upvotes: 5

Deepak
Deepak

Reputation: 1441

You can use following code using UIAlerController for XCode 6 and IOS 8

UIAlertController * alert=   [UIAlertController
                                 alertControllerWithTitle:@"Title"
                                 message:@"Your Message"
                                 preferredStyle:UIAlertControllerStyleAlert];

   UIAlertAction* ok = [UIAlertAction
                        actionWithTitle:@"OK"
                        style:UIAlertActionStyleDefault
                        handler:^(UIAlertAction * action)
                        {
                            [alert dismissViewControllerAnimated:YES completion:nil];

                        }];
   UIAlertAction* cancel = [UIAlertAction
                            actionWithTitle:@"Cancel"
                           style:UIAlertActionStyleDefault
                           handler:^(UIAlertAction * action)
                           {
                               [alert dismissViewControllerAnimated:YES completion:nil];

                           }];

   [alert addAction:ok];
   [alert addAction:cancel];

   [self presentViewController:alert animated:YES completion:nil];

For ActionSheet

UIAlertController * alert=   [UIAlertController
                                     alertControllerWithTitle:@"Title"
                                     message:@"Your Message"
                                     preferredStyle:UIAlertControllerStyleActionSheet];

Upvotes: 0

iHulk
iHulk

Reputation: 4909

It should be noted, that UIAlertView and UIActionSheet is deprecated in iOS 8. You can check out this question or the apple link. May be it will help you.

Upvotes: 0

Related Questions