TLYShyNavBar icon indicating copy to clipboard operation
TLYShyNavBar copied to clipboard

Scroll to top getting affected.

Open notDanish opened this issue 9 years ago • 20 comments

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?

notDanish avatar Jan 04 '16 18:01 notDanish

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

[self.tableView setContentOffset:CGPointMake(1,1) animated:YES];

Mazyod avatar Jan 04 '16 19:01 Mazyod

@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.

notDanish avatar Jan 04 '16 19:01 notDanish

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

Mazyod avatar Jan 04 '16 19:01 Mazyod

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

Haven't changed any other setting.

notDanish avatar Jan 04 '16 20:01 notDanish

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

Mazyod avatar Jan 04 '16 20:01 Mazyod

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.

ghost avatar Jan 06 '16 09:01 ghost

Thanks @oyalhi, I figured it would be easily reproducible

Mazyod avatar Jan 06 '16 19:01 Mazyod

@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?

notDanish avatar Jan 06 '16 23:01 notDanish

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

Mazyod avatar Jan 06 '16 23:01 Mazyod

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

notDanish avatar Jan 06 '16 23:01 notDanish

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

Mazyod avatar Jan 06 '16 23:01 Mazyod

@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 avatar Jan 07 '16 15:01 notDanish

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

notDanish avatar Jan 12 '16 17:01 notDanish

@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.

Mazyod avatar Jan 12 '16 18:01 Mazyod

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

worthbak avatar Jan 22 '16 16:01 worthbak

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

Mazyod avatar Jan 30 '16 11:01 Mazyod

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.

ndrewh avatar Jan 31 '16 00:01 ndrewh

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

RahuliOSDev avatar Feb 17 '16 11:02 RahuliOSDev

@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.

szweier avatar Feb 23 '16 15:02 szweier

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.

jonahsiegle avatar Dec 10 '16 22:12 jonahsiegle