多个按钮,不同操作

- (IBAction)SelectAction:(UISegmentedControl *)sender {
    SEL selectors[] = {
        @selector(applyAmount),
        @selector(pushVC)
    };

    if (sender.selectedSegmentIndex < sizeof(selectors) / sizeof(SEL)) {
        void(*imp)(id, SEL) = (typeof(imp))[self methodForSelector:selectors[sender.selectedSegmentIndex]];
        imp(self, selectors[sender.selectedSegmentIndex]);
    }

    
    
}

你可能感兴趣的:(多个按钮,不同操作)