简体   繁体   中英

Selector method not getting called

I am trying to create a dropdown menu using the MKDropDownMenu library. I am also getting a view. But when click on it does not drops down and nothing happens. When I went deep inside. I found that the button in the component button's selector method is not getting called.

This is the line where the selector method name is declared.

[button addTarget:self action:@selector(selectedComponent:) forControlEvents:UIControlEventTouchUpInside];

Below is the actual method "selectedComponent" :

- (void)selectedComponent:(MKDropdownMenuComponentButton *)sender {
    if (self.transition.isAnimating) {
        return;
    }
    if (sender == nil) {
        [self closeAllComponentsAnimated:YES];
    } else {
        NSInteger selectedIndex = [self.buttons indexOfObject:sender];
        if (selectedIndex == self.selectedComponent) {
            [self closeAllComponentsAnimated:YES];
        } else {
            [self openComponent:selectedIndex animated:YES];
        }
    }
}

The most strange thing is that this private method is called in the example project given on github on the following link:

https://github.com/maxkonovalov/MKDropdownMenu/tree/master/Example

And for your information I am using swift and used pod to install this library.

Any help and suggestions will be appreciated..

Did you set the delegate and data source of the drop down menu?

dropdownMenu.dataSource = self;
dropdownMenu.delegate = self;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM