Application crash due to UIAlertController in ios 8

I am developing a custom keyboard app and in this app I want to show the UIAlertController but it crashes with the following error.

Application terminated due to uncaught "NSGenericException", reason: "Your application presented a UIAlertController () of style UIAlertControllerStyleActionSheet. ModalPresentationStyle UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this sourcePresentationPopover. You must provide location information for this sourcePresentationPopover. You must provide location information for this sourcePresentationPopover. , and sourceRect or barButtonItem. If this information is not known when you present the alert controller, you can provide it in the UIPopoverPresentationControllerDelegate -prepareForPopoverPresentation method. '

I used the following code ...

     UIAlertController * alert=   [UIAlertController
                             alertControllerWithTitle:@"Info"
                             message:@"You are using UIAlertController"
                             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];

      

So how can I decide?

+3


source to share





All Articles