iPhone: Error when using the FPPopover class when using it with a UIBarButtonItem

后端 未结 4 1099
野的像风
野的像风 2021-01-11 10:19

I am using the FPPopover class which creates popups for iPhones. I followed the exact steps that are in the readme file but instead of using a UIbutton from a xib file, I am

4条回答
  •  暖寄归人
    2021-01-11 11:01

    the presentPopoverFromView is only accepting a UIView subclass. UIBarButtonItem is not a subclass of UIView, so you need to find the view related to that button item. This is the solution I'm using with FPPopoverController

        UIBarButtonItem *buttonItem = sender;
        UIView* btnView = [buttonItem valueForKey:@"view"];
        //On these cases is better to specify the arrow direction
        [popover setArrowDirection:FPPopoverArrowDirectionUp];
        [popover presentPopoverFromView:btnView];
    

    This should work! Let me know!

提交回复
热议问题