I am making a profile view on iOS which has three tabs like twitter app. I am using one table view and when user taps on these tabs I am reloading it from other data sources. But I want to keep the section header to be on the top independent of these data source models.Is there is any way to achieve it?
Sometimes when user taps on button of section header to switch the table view data source and reload again, but section header view either gets hide or misplaced from its original top position, Its a weird kind of bug, Any hint what's going on here?
Edit : - One important thing is I am having pull to refresh also here.
you can make a unique view to store your section Header,then put the view head of the controller. That can achieve your goal.
But I want to keep the section header to be on the top independent of these data source models.Is there is any way to achieve it?
If I understand you correctly you maybe better served by using the table header view property. Why? because would give you the independence you want from the data source reloading, but maintain your ability to fire the data source reload from your three controls.
You could also follow @WolfLink's advise and put a view above your table view to achieve the same thing.
This is course dependent of how you use your table sections. See this SO question for adding a header view to your table view.
EDIT
If you want the current section view to always be at the top of it's super view then you should re-arrange you view controller's view hierarchy so that your section header view is implemented out side of the table view.
ViewController's subviews
---> view containing your three buttons(Current section header view)
---> table view
---> toolbar
This way even when the user scrolls the table view, the three button view will still stay at the top of the screen.
I think it is a scrolling issue, i have had similar issue before, UITableView is built on top of UIScrollView, and scroll view has setContentOffset method, call this after reload and set offset to (0,0)
You can use this library: https://github.com/toandk/DTTableView
In the example, there is a table view DTParallaxTableView initiated with a header view: DTParallaxHeaderView and a UIVIew (which can be a tab bar like in this sample).
You can disable the parallax effect if not useful and use it to launch the pull to refresh.
Or search here and find the one that match with your use case! https://www.cocoacontrols.com/search?q=pull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With