Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Scroll to top getting affected. #111

Open
notDanish opened this issue Jan 4, 2016 · 20 comments
Open

Scroll to top getting affected. #111

notDanish opened this issue Jan 4, 2016 · 20 comments

Comments

@notDanish
Copy link

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
Copy link
Contributor

Mazyod commented Jan 4, 2016

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

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

@notDanish
Copy link
Author

@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
Copy link
Contributor

Mazyod commented Jan 4, 2016

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

@notDanish
Copy link
Author

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

Haven't changed any other setting.

@Mazyod
Copy link
Contributor

Mazyod commented Jan 4, 2016

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

@ghost
Copy link

ghost commented Jan 6, 2016

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
Copy link
Contributor

Mazyod commented Jan 6, 2016

Thanks @oyalhi, I figured it would be easily reproducible

@notDanish
Copy link
Author

@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
Copy link
Contributor

Mazyod commented Jan 6, 2016

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

@notDanish
Copy link
Author

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

@Mazyod
Copy link
Contributor

Mazyod commented Jan 6, 2016

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

@notDanish
Copy link
Author

@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
Copy link
Author

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

@Mazyod
Copy link
Contributor

Mazyod commented Jan 12, 2016

@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
Copy link

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
Copy link
Contributor

Mazyod commented Jan 30, 2016

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
Copy link
Contributor

ndrewh commented Jan 31, 2016

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
Copy link

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
Copy link
Contributor

szweier commented Feb 23, 2016

@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
Copy link

jonahsiegle commented Dec 10, 2016

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.

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

No branches or pull requests

7 participants