Pageboy icon indicating copy to clipboard operation
Pageboy copied to clipboard

iOS 11 Large titles

Open axmav opened this issue 6 years ago • 34 comments

Hello!

When using: self.navigationController?.navigationBar.prefersLargeTitles = true in TabViewController, and UITableViewControllers as viewControllers - everything OK, but navigation not collapsing when i scroll tableview. How to connect scrolling with LargeNavigation?

Should be: ezgif com-video-to-gif 5

axmav avatar Nov 29 '17 19:11 axmav

This issue is ios 11 Bug. use this code self.navigationItem.largeTitleDisplayMode = .never self.navigationItem.largeTitleDisplayMode = .automatic

and you see the Magic @Mazorati

farshadmb avatar Nov 29 '17 19:11 farshadmb

@farshadmb thanks for your reply. If you think that i cant use google with first solution - you make mistake. Still not working. I suppose that UILargeNavigationItem requires uiscrollview as superview. i upload code: https://github.com/Mazorati/test8/blob/master/test8/Test2ViewController.swift

axmav avatar Nov 29 '17 20:11 axmav

@Mazorati. Ok, I will check it out. thanks for provide a code

farshadmb avatar Nov 29 '17 21:11 farshadmb

@Mazorati @farshadmb I think this is an issue related to how UIKit internally handles the transitioning of the nav bar titles and the hierarchy that Pageboy uses.

Basic VC hierarchy:

PageboyViewController
     -> UIPageViewController
          -> [ChildViewControllers]

UINavigationController obviously hooks into any scroll view that is present in the visible view controller and uses it to transition the bar, so I'm not sure if there is any way to manually point to a UIScrollView for this, or whether we can get the navigation controller to find the child view controller scroll view.

Will need some investigation...

msaps avatar Dec 01 '17 08:12 msaps

Does Pageboy work with UINavigationBar.prefersLargeTitles in iOS 11? Thanks a lot.

jnshey avatar Feb 12 '18 07:02 jnshey

@jnshey I haven't had chance to investigate the above mentioned bug any further as of yet, so I'm not sure how well Pageboy works with the large titles. Will prioritise it to look at ASAP. 👍

msaps avatar Feb 12 '18 20:02 msaps

@Mazorati @jnshey as suspected I don't think this will be possible due to the way that it's implemented in iOS. 😢

UINavigationController apparently only looks at the first subview in the child view controller for whether to respond to UIScrollView events. With Pageboy the scroll view is a few child levels deeper:

-> UINavigationController
     -> PageboyViewController
          -> UIPageViewController (UIKit will be looking here for the scroll view)
               -> YourChildViewController
                    -> YourScrollView 

I can't seem to see any real solution on the dev forums or online unfortunately - the best people have come up with is changing the large title mode in an animation block: Stack Overflow

msaps avatar Feb 13 '18 16:02 msaps

@msaps Will it be possible if one wraps the PageboyViewController's view in a giant UIScrollView?

Like this:

UINavgationController
  -> ChildViewController (whose first subview is a UIScrollView that contains PageboyViewController's main view)

jnshey avatar Feb 13 '18 16:02 jnshey

Hi! Bad but working method: Add UIScrollView to PageBoyViewController. Important - UIScrollView must have index 0. (see here) In YourScrollView we can use scrollViewDidScroll and set offset on our "main" UIScrollView.

upd: Its work. At least in Tabman gif

vanab avatar Mar 04 '18 04:03 vanab

@vanab looks interesting! Would you be able to post your view hierarchy so we can get a better look?

msaps avatar Mar 04 '18 12:03 msaps

@msaps this TabmanViewController. UIScrollView at index 0(this is important). 2018-03-04 18 10 44 image

and in all childViewcontrollers

func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if #available(iOS 11.0, *) {
                let offset = scrollView.contentOffset
                tabmanVC.scrollView.contentOffset = offset
          }
}

vanab avatar Mar 04 '18 14:03 vanab

@vanab ah perfect thank you! I've done a little demo project which uses your methods - seems to work great:

Pageboy-NavCollapse.zip

Will try and get this integrated into Pageboy so that it provides support for this natively 🙏

msaps avatar Mar 04 '18 14:03 msaps

@msaps your demo works fine but not smoothly enough. I can't figure out why. @vanab can you provide your demo please? My case also has a tab bar, and I hope the large title navigation bar in your demo shrinks as smoothly as system's.

gaojinhsu avatar Jun 03 '18 10:06 gaojinhsu

@gaojinhsu hmmmm. Looks like iOS 11.3 problem. See my gif here . Now it no work too

vanab avatar Jun 04 '18 20:06 vanab

any updates for iOS 11.3 or 11.4? I think there is the same problem on iOS 11.4

wow-such-amazing avatar Jun 11 '18 11:06 wow-such-amazing

@vanab There must be some ways. At least, I've seen some apps make it. https://itunes.apple.com/cn/app/yuan-fu-dao-chu-gao-zhong/id974568444?mt=8

gaojinhsu avatar Jun 15 '18 07:06 gaojinhsu

@gaojinhsu i have no idea. in your app nav bar not resizing. pull-to-refresh not conform iOS 11 guidelines. it should be inside navbar, not headerView

vanab avatar Jun 15 '18 08:06 vanab

Is this still in progress?

Vortec4800 avatar Jul 05 '18 21:07 Vortec4800

@Vortec4800 yeah sorry it is - working on it as part of Pageboy 3.0. Also rebuilding Tabman for 2.0 so got quite a lot going on! 😄

msaps avatar Jul 06 '18 08:07 msaps

Well we use Pageboy and Tabman for various things, so we'll be grateful for both.

Do you have an ETA on 3.0? We've got a project that's scheduled for release early August and it would be nice to have the large titles working in it. If not, perhaps I could work in a workaround for the time being.

Vortec4800 avatar Jul 06 '18 13:07 Vortec4800

@Vortec4800 unfortunately no ETA just yet. Though the Pageboy release is a lot more iterative than Tabman, so hopefully can get that out a little quicker.

Will endeavour to prioritise getting something sorted for the large title issue in 11.3+

msaps avatar Jul 09 '18 08:07 msaps

No problem. Thanks for all the work on this!

Vortec4800 avatar Jul 09 '18 13:07 Vortec4800

Unfortunately didn't make much more progress with this after the issue that arose in iOS 11.3. I've removed it from (just released) Pageboy 3.

I have kept the feature/large-nav-title-support branch open with the changes, now up to date with master. So I wouldn't say this is completely dead, just unfortunately couldn't figure it out just yet 😢

msaps avatar Nov 13 '18 20:11 msaps

I tried using this library to collapse the title bar but still no luck https://github.com/andreamazz/AMScrollingNavbar

junaidxabd avatar Dec 12 '18 20:12 junaidxabd

Is there a way to collapse the tab bar though?

junaidxabd avatar Dec 12 '18 20:12 junaidxabd

worked in this way func scrollViewDidScroll(_ scrollView: UIScrollView) { if #available(iOS 11.0, *) { let offset = scrollView.contentOffset tabmanVC.scrollView.contentOffset = offset tabmanVC.scrollView.panGestureRecognizer.state = scrollView.panGestureRecognizer.state } }

sonrier avatar Jan 23 '19 09:01 sonrier

@sonrier where would i override scrollViewDidScroll ?

sunnysidevibes avatar Feb 04 '19 17:02 sunnysidevibes

Hey @vanab @sonrier, just found this and I tried the exact same way. Didn't work on 13.2.2. Did you try recently? Or is there any other ways to do the hack here? Thanks

wx0165927473 avatar Feb 12 '20 21:02 wx0165927473

I am trying this on iOS 13.1. And I get this to work but it is very choppy. Has anyone iterated on this or found an alternative?

tiarnann avatar Apr 01 '20 18:04 tiarnann

No luck so far, maybe creating a tableView then adding the pageViewController inside the tableViewCell?

brunohenriquesk1 avatar May 09 '20 01:05 brunohenriquesk1