Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/ARSPopover.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/// Use this property to configure where popover's arrow should be pointing.
@property (nonatomic, assign) UIPopoverArrowDirection arrowDirection;

/// The bar button item on which to anchor the popover.
@property (nonatomic, assign) UIBarButtonItem *barButtonItem;

/// The view containing the anchor rectangle for the popover.
@property (nonatomic, weak) UIView *sourceView;

Expand Down
9 changes: 7 additions & 2 deletions Source/ARSPopover.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ - (void)insertContentIntoPopover:(void (^)(ARSPopover *popover, CGSize popoverPr
#pragma mark - Popover Presentation Controller Delegate

- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController {
self.popoverPresentationController.sourceView = self.sourceView ? self.sourceView : self.view;
self.popoverPresentationController.sourceRect = self.sourceRect;
if (self.barButtonItem) {
self.popoverPresentationController.barButtonItem = self.barButtonItem;
} else {
self.popoverPresentationController.sourceView = self.sourceView ? self.sourceView : self.view;
self.popoverPresentationController.sourceRect = self.sourceRect;
}

self.preferredContentSize = self.contentSize;

popoverPresentationController.permittedArrowDirections = self.arrowDirection ? self.arrowDirection : UIPopoverArrowDirectionAny;
Expand Down