Show NSSegmentedControl menu when segment clicked, despite having set action

后端 未结 4 1488
清酒与你
清酒与你 2021-01-02 12:39

I have an NSSegmentedControl on my UI with 4 buttons. The control is connected to a method that will call different methods depending on which segment is clicked:



        
4条回答
  •  走了就别回头了
    2021-01-02 12:57

    Subclass NSSegmentedCell, override method below, and replace the cell class in IB. (Requires no private APIs).

    - (SEL)action
    {
        //this allows connected menu to popup instantly (because no action is returned for menu button)
        if ([self tagForSegment:[self selectedSegment]]==0) {
            return nil;
        } else {
            return [super action];
        }
    }
    

提交回复
热议问题