Modal Popover not centered with UIBarButtonItem
See original GitHub issueThis is related to https://github.com/grahammendick/navigation/pull/443.
Seems like there is an issue with centering the Action Sheet on iPad.
When the image
prop is provided to the BarButton
, it seems to be the most obvious offender. It is less noticeable when the title
or systemItem
is used.
A potential cause for could be found in the NVBarButton.m
in:
- (void)layoutSubviews
{
[super layoutSubviews];
UIView *buttonView = ((UIView *) [self.button valueForKey:@"view"]);
UIView *barView = buttonView.superview;
UIView *labelView = buttonView.subviews.count > 0 ? buttonView.subviews[0] : buttonView;
CGRect labelFrameInBar = [buttonView convertRect:labelView.frame toView:barView];
self.frame = [barView convertRect:labelFrameInBar toView:nil];
}
According to this StackOverflow Post, the convertRect
does not accurately get the frame of UIBarButtonItem
when not created with init(customView: UIView)
and/or when the UINavigationBar
has not laid out all of its subviews.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (11 by maintainers)
Top Results From Across the Web
UIPopover presentFromBarButton off center - Stack Overflow
I've noticed in a project that the positioning of a popover over a right bar button item seems to be off to the...
Read more >The Swift Swift Tutorials: Adding Modal Views and Popovers
This is what modal views and popovers are. ... Modals do not do their own housekeeping like navigation ... Move it to the...
Read more >ActionSheet Popover on iPad in Swift | by Nick Meehan
Definitely not what I was looking for. I want the popover to appear centered in the view. So, I'll need to go the...
Read more >Programming-iOS-Book-Examples/ViewController.swift at ...
//hmm, this feels like a bug: merely examining the presentation controller... //freezes it so that it never becomes a popover presentation controller!
Read more >Chapter 22. Popovers and Split Views - apeth.com
NewGameController* dlg = [NewGameController new]; UIBarButtonItem* b ... The popover controller's view controller's modalInPopover is NO, and the user taps ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @Dwar3xwar & @ndco. See the release notes for your credit
Nice to see this get resolved!