Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActionsheet delegate method calling twice in ios8?

In ios8 delegate methods of UIActionSheet calling multiple times

  - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

I have checked in ipad 2 with IOS 8

like image 903
Sunny Shah Avatar asked Sep 20 '14 07:09

Sunny Shah


3 Answers

Its a bug of the ios 8..

As the @rob said UIActionSheet is deprecated in iOS 8. (UIActionSheetDelegate is also deprecated.)

To create and manage action sheets in iOS 8 and later, use UIAlertController

like image 156
Sunny Shah Avatar answered Nov 01 '22 05:11

Sunny Shah


This is indeed the current behavior that I've seen reported in several places. It does appear to be a bug and hopefully will be fixed soon but no way to know for sure.

like image 28
Dima Avatar answered Nov 01 '22 06:11

Dima


You should UIAlertController to replace all AlertView and ActionSheet in iOS8. If your target lower than iOS8, then you should check version and add more code

For example, this code is for iOS8 ActionSheet

-(void)testActionSheet{
    UIAlertController* alertAS = [UIAlertController alertControllerWithTitle:@"Test ActionSheet"
                                                                   message:nil
                                                            preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Action" style:UIAlertActionStyleDefault
                                                          handler:^(UIAlertAction * action) {
                                                              NSLog(@"Action");
                                                          }];
    [alertAS addAction:defaultAction];
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    }];
    [alertAS addAction:cancleAction];
    [self presentViewController:alertAS animated:YES completion:nil];

}
like image 25
LE SANG Avatar answered Nov 01 '22 06:11

LE SANG