0

I'm presenting an ActionSheet with UIAlertController when a tableView cell is selected.

My code is like this:

 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Select Action"
                                                               message:nil
                                                        preferredStyle:UIAlertControllerStyleActionSheet];
 [alert addAction:[UIAlertAction actionWithTitle:@"Action 1"
                                          style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction * _Nonnull action) 
 {
        [self handleAction1Selected];
 }]];

 [alert addAction:[UIAlertAction actionWithTitle:@"Action 2"
                                          style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction * _Nonnull action) 
 {
        [self handleAction2Selected];
 }]];

 [alert addAction:[UIAlertAction actionWithTitle:@"Action 3"
                                          style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction * _Nonnull action)
 {
        [self handleAction3Selected];
 }]];

 [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];

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

This code is called in [tableView:didSelectRowAtIndexPath:] method, however, there is always huge lag after I select a tableview cell until the ActionSheet actually pops up.

The lag ranges between 1 second to 10, sometimes even 20 seconds.

This is pretty simple code without much configuration, is there anything I'm doing wrong or it's just a bug for Apple?

Pablo
  • 2,834
  • 5
  • 25
  • 45
Ray
  • 272
  • 2
  • 13
  • 1
    I searched and found [this](http://stackoverflow.com/questions/26469268/delay-in-presenting-a-modal-view-controller). – Droppy Jun 17 '16 at 10:26
  • You have to add the alert controller to your custom cell class rather then adding it in the [tableView:didSelectRowAtIndexPath:] method – Kunal Kumar Jun 17 '16 at 10:27

0 Answers0