question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal Popover not centered with UIBarButtonItem

See original GitHub issue

This 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:closed
  • Created 3 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
grahammendickcommented, Nov 23, 2020

Thanks @Dwar3xwar & @ndco. See the release notes for your credit

0reactions
Dwar3xwarcommented, Nov 25, 2020

Nice to see this get resolved!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found