Pop over doesn't point over the button

前端 未结 3 526
遥遥无期
遥遥无期 2021-02-05 03:49

I have an application that is compatible with both iPhone and iPad layouts. For iPhone layout I have created Action Sheet and Pop over for iPad. The problem is pop over\'s arrow

3条回答
  •  [愿得一人]
    2021-02-05 04:17

    Set the sourceView and sourceRect as the button and button.bounds.
    You can choose the permittedArrowDirections depending on the layout of your view.

    actionSheet.popoverPresentationController?.sourceView = button
    actionSheet.popoverPresentationController?.sourceRect = button.bounds;
    actionSheet.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Left;
    

    If the button is a BarButtonItem use this code.

    actionSheet.popoverPresentationController?.barButtonItem = button
    actionSheet.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Up;
    

提交回复
热议问题