UIBarButtonItem with UIButton as CustomView - from UIButton, how to access the UIBarButtonItem its in?

前端 未结 5 777
误落风尘
误落风尘 2021-01-05 06:51

I have a UIBarButtonItem with UIButton as custom view.

The UIButton has a addTarget:action: on it. In the action

5条回答
  •  旧巷少年郎
    2021-01-05 07:24

    // get the UIBarButtonItem from the UIButton that is passed in sender
    UIToolbar *toolbar = (id)[sender superview];
    UIBarButtonItem *ourButtonItem = [toolbar items][2];//pick the right index
    [parkingPopOver_ presentPopoverFromBarButtonItem:ourButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    

提交回复
热议问题