Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigationItem.titleView is not shown after presenting #60

Closed
ElfSundae opened this issue Apr 9, 2016 · 3 comments
Closed

navigationItem.titleView is not shown after presenting #60

ElfSundae opened this issue Apr 9, 2016 · 3 comments

Comments

@ElfSundae
Copy link

Reproduce:

  1. InPopupViewController1.m , set titleView in viewDidLoad

    self.navigationItem.titleView = [UIButton buttonWithType:UIButtonTypeInfoLight];
    
  2. Build and run the example project, tap the first row on the table view. You can see that the titleView is not shown.

  3. Now tap the "Next" bar item on the opened view controller, and then tap the "Back" arrow, now you can see that the titleView is shown.

I found this bug on my iPhone 6 Plus which installed iOS 8.4, I also tested in iPhone Simulator 9.0/9.1/9.2 and it worked fine.

After debugging, I found that the titleView was removed from popupController's navigationBar after presenting popupController. This is so strange. Maybe it is an iOS bug.

Temporary Fix:

Re-add titleView to navigationBar when viewDidAppear, or reset navigationItem.titleView:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // BugFix: navigationBar's titleView is not shown after presenting STPopupController.
    // See: https://github.com/kevin0571/STPopup/issues/60
    if (self.popupController) {
        UIView *titleView = self.popupController.navigationBar.topItem.titleView;
        if (titleView && !titleView.superview) {
            // Re-add titleView to the navigationBar
            // [self.popupController.navigationBar addSubview:titleView];

            // Or: invoke -[STPopupController updateNavigationBarAniamted]
            self.navigationItem.titleView = titleView;
        }
    }
}
@kevin-lyn
Copy link
Owner

Related to #59 . Will look into this issue.

@ElfSundae
Copy link
Author

@kevin0571 Did you try to set titleView on iOS9 device? I have no device running iOS 9, maybe it's a previous iOS bug.

@kevin-lyn
Copy link
Owner

Yes, I tried. Works well on iOS 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants