telly / TLYShyNavBar

Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
MIT License
3.73k stars 427 forks source link

Scroll to top getting affected. #111

Open notDanish opened 8 years ago

notDanish commented 8 years ago

I'm using this line of code : [self.tableView setContentOffset:CGPointMake(0,0) animated:YES]; for my tableView that is present in a viewController embedded in shyNavBar.

The code was working perfectly till I changed the nav bar to shyNavBar. Now it doesn't scroll completely to top. The top of the first cell seems to get cut off a little until i manually scroll it down.

Is the shyNavBar somehow interfering with the scroll of the tableView?

Mazyod commented 8 years ago

@notDanish Before trying to dig into this, can you try this "hail Mary" attempt:

[self.tableView setContentOffset:CGPointMake(1,1) animated:YES];
notDanish commented 8 years ago

@Mazyod Tried, it still has the same issue. CGPointMake(0,0) CGPointZero CGPointMake(1,1) all working the same way. For some reason I see the tableView frame as :(0, -44, width, height) instead of what i'd hope to be :(0, 0, width, height) when I log after the code.

Mazyod commented 8 years ago

@notDanish Can you please tell me more about your shyNavBar configuration? Sticky, extension height, ... etc?

notDanish commented 8 years ago

@Mazyod Nothing fancy at all. Just that one line of code self.shyNavBarManager.scrollView = self.tableView;

Haven't changed any other setting.

Mazyod commented 8 years ago

@notDanish Thanks, I'll try to look into it, nothing immediately comes to mind.. (Please note UITableViewController is not supported)

ghost commented 8 years ago

I have the same problem. In some views I use extensionView, and some don't. None of them are scrolling to top correctly. The problem can be seen in your own swift sample demo code as well.

Mazyod commented 8 years ago

Thanks @oyalhi, I figured it would be easily reproducible

notDanish commented 8 years ago

@Mazyod Also I noticed the scroll to top on tapping status bar feature which I believe is native to iOS 9 is not working anymore since I started using TLYShyNavBar. Is this a known issue?

Mazyod commented 8 years ago

@notDanish no, I believe it was fixed in the past, but it may have regressed

notDanish commented 8 years ago

@Mazyod Can you direct me to the fix or the issue please?

Mazyod commented 8 years ago

@notDanish sure, this is the one I had in mind #82

notDanish commented 8 years ago

@Mazyod I checked the commit you made for that issue. It is not really affecting in this issue. On tapping the status bar, the scrollView (tableView here) doesn't scroll to top and hence the method - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView isn't called.

Do you know if the touch event on status bar is being overridden by TLYShyNavBar or something weird like that?

notDanish commented 8 years ago

Hi @Mazyod Was wondering if you had any update? Thanks a lot!

Mazyod commented 8 years ago

@notDanish Yeah, sorry about that. There is no specific way the library overrides the status bar touch behavior. However, the status bar is coupled with the scroll view on this, since a touch on the status bar leads to an event on the scroll view. The library heavily manages the scroll view, so maybe something missing on that front.

I am currently in "management" mode, will be happy to answer questions and review PRs, but can't really dig into the code. Will try to allocate more time soon.

worthbak commented 8 years ago

While I wouldn't call it particularly critical, I'm seeing this issue as well - using setContentOffset to scroll a scrollView up to the top programmatically doesn't fully work. I recorded a quick video to show the behavior I'm seeing (tapping the tab bar should scroll everything to 0,0, but as you can see, it stops a bit short): https://www.dropbox.com/s/5j5es7wburff5n8/scrolling.mov?dl=0

Mazyod commented 8 years ago

very interesting demo @worthbak, thanks for taking the time. I think there is some resistance the library might be applying, and maybe we can take care of it using the middleMan by listening to the scroll to top ...

ndrewh commented 8 years ago

I'm having this issue also, except I'm not actually calling setContentOffset...I only have two lines of code:

self.shyNavBarManager.scrollView = self.tableView;
self.shyNavBarManager.extensionView = myOtherView

Without even touching the scrollview, the application starts and isn't scrolled all the way up just as shown in @worthbak's video.

EDIT: I suppose the issue I'm having is #101, which might be related to this one after all.

RahuliOSDev commented 8 years ago

i' m having an issue in iphone 4s. when i have less number of cells in uitableview then navigation bar is behaving unexpectedly while scrolling.

scenario: Use i phone 4s number of cells = 11 height is default tableview height

szweier commented 8 years ago

@notDanish tapping the status bar seems to work fine for me when using the shyNavBarManager. I did however see this issue before for a different reason that may apply to your situation. Basically if any other views exist on that tableview the can "scroll to top" it will negate the scrolling to top capability. You'd need to setScrollsToTop to NO. So if a cell has a UITextView, UIScrollView etc. it will break scroll to top on the table view. Hope that helps.

jonahsiegle commented 7 years ago

For anyone still having this issue, use self.tableView.scrollRectToVisible(CGRect(x:0, y:0, width:1, height:1), animated: true) instead of setContentOffset:. The scrollview will scroll to the top and maintain the correct layout with extensionViews and the NavigationBar.