SDCAlertView callback clickButtonAtIndex not called while running iOS

For any reason, the callback SDCAlertView clickButtonAtIndexfrom the SDCAlertView POD (see code block below) is never called. SDCAlertView shows, but after I selected the button in my warning, the calling call will not be called. Apples alertViewwork great with this callback. I imported <SDCAlertView.h>and <UIView+SDCAutoLayout.h>in my classes header file and has not started work space without the project, to POD was available.

Anyone using SDCAlertView is facing this problem or seeing something that I am doing wrong?

- (void)alertView:(SDCAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; {
        // *** NEVER MAKES IT IN HERE ***
        switch (buttonIndex) {
        case 0:
            NSLog(@"alertView: Cancel");
            break;
        case 1:
            NSLog(@"alertView: OK");
            break;
        default:
            NSLog(@"Blowing It: Alert not handled");
            break;
    }
}

Below is the setting of one of the SDCAlertView in my project, which is declared in my file MainViewController.m. I add a slider to adjust the volume for the headset.

    // Setup Slider for Alert View
    UISlider *volumeSlider = [[UISlider alloc] initWithFrame:CGRectMake(20, 50, 200, 200)];
    volumeSlider.maximumValue = 10.0;
    volumeSlider.minimumValue = 1.0;
    [volumeSlider addTarget:self action:@selector(sliderHandler:) forControlEvents:UIControlEventValueChanged];

    // Setup Alert View
    SDCAlertView *noHeadsetAlertView =
               [[SDCAlertView alloc]
                initWithTitle:@"No Headset"
                message:@"You need a headset you fool!"
                delegate:nil
                cancelButtonTitle:nil
                otherButtonTitles:@"Cancel", @"Use Mic", nil];
    [volumeSlider setTranslatesAutoresizingMaskIntoConstraints:NO];
    [noHeadsetAlertView.contentView addSubview:volumeSlider];

    [volumeSlider sdc_pinWidthToWidthOfView:noHeadsetAlertView.contentView offset: -20];
    [volumeSlider sdc_horizontallyCenterInSuperview];

    [noHeadsetAlertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[volumeSlider]|"
                                                                              options:0
                                                                              metrics:nil
                                                                                views:NSDictionaryOfVariableBindings(volumeSlider)]];

    [noHeadsetAlertView show];

SDCAlertView GitHub.

+4
1

. nil self, .

+1

Source: https://habr.com/ru/post/1528017/


All Articles