UITableview scrolling to top after popViewControllerAnimated is called - ios

I am having an issue with an UITableView.
I am displaying a collection of tracking records. After the user taps on a cell, a detail view controller is displayed with detailed data. My problem is after I call popViewControllerAnimated:YES from the Detail view controller, my table view is reseted and scrolls to the top position automatically.
I am not calling [myTable reloadData]; on viewWillAppear and I find this behavior kinda strange.
Does anyone have an idea what I might be missing here?
Any help or tip would be appreciated!
Thanks,
Granit

It's a known issue.
The more the estimatedRowHeight differs from the actual height, the more the table will jump when the push segue happens. The easiest workaround is to use a much better estimate.

if you don't call reloadData then either you re-add the table somewhere or you popped ViewController was reloaded because of some reason. Does ViewDidLoad called when you pop back?
How about storing the table scrolling state? (contentOffset)

Related

TableView issue (weird Visualization)

I have a class (movieTable.m) with TableView populated with many cells.
As i Clicked one of them, the navigation controller brings in the other scene done in the StoryBoard.
When i get back, still with Navigation Controller, i find the TableView moved little bit down.
As I debugged the Hierarcy i found that UITableViewWrapperView is scrolled down from UITableView.
Edit: The funny thing is: if i put a UiSegmentedControl in the UiView the issue disappears.
Why this? i didn't tell the code to move it. Maybe I'm getting wrong with the timing?
so to making clear the ideas, there's two images:
Hierarchy before/after changing the scene
The Code if you want to see it is in this following GitHub: GitHub
Thank you all for helping&hints.
this worked for me
add
self.automaticallyAdjustsScrollViewInsets = NO;
to your viewDidLoad of the moveiTable.m

UInavigation popping back view and updating previous view's content

I have a collection view with cells that can be tapped, and push to a second view. The problem is, the changes I make in the second view are suppose to alter the first view(collection view) when the user pops back to it. By adding a new cell with an image.I can't seem to get the content to update.
I tried to use viewWillAppear on the first view and [colectionview reloadData] it doesn't seem to work. Anyone got a fix for this? help would be greatly appreciated.
Have you debugged either UIcollectionViewDataSource methods are being called? Make sure you have set the delegate and datasource off collection view. What is the data source of collection view? Please paste your code of second view where you are making changes.
I fixed the problem By calling [collectionview reloadData] in viewDidAppear instead of viewWillAppear, only problem is there is a noticeable amount of lag before the cell appears. Anyone know a better way?

uitableview not reload again in half view like facebook Half view

I have made an application, in which I have used uitableview in Half view like facebook, when I go to half view using swipe, then uitableview does not reload, but it reloads when I run it first time,So if anyone knows about it, please tell me.
Thanks
I have subclassed JASidePanel and in that subclass I override a method as show below:
- (void)toggleLeftPanel:(id)sender
{
[((MyLeftPanelViewController *)self.leftPanel) myReloadMethodInMyLeftPanelViewController];
[super toggleLeftPanel:sender];
}
This works when using the left navigation button to navigate to the left panel, but I think a similar approach would work for swipe. I figured this out by looking in the header file for JASidePanel and then tracing the code.

UITableView scrolling odd behaviour

I have a TableViewController in my app (well several but this only happens on this particular one).
The content is driven from Core Data using an NSFetchedResultsController and the TVC is a NSFetchedResultsControllerDelegate and uses the methods for updating the table based on content changes (i.e. it runs the beginUpdates, endUpdates etc...).
I've done this a number of times before and so just use the same code. (Also can be found on Ray Wenderlich's site).
Anyway, I have a view (pushed from the TVC) that adds new items in to the CoreData DB. This new item should then be added into the TVC's table.
This is all working fine. I view the Table scroll up and down it fine. Click add. Add the new item. Push back to the TableView and I can see the new item...
BUT
The tableView doesn't allow me to scroll all the way to the bottom now. I can see the new data in the table by scrolling to the bottom and holding the screen but when I let go the tableView bounces back so that I can no longer see it.
I have checked several things...
The frame of the TableView is unchanged before and after.
The contentSize of the tableView DOES change to accommodate the added cells.
When scrolling the minimum contentOffset is 0 both before and after (this is correct).
When scrolling the MAXIMUM contentOffset is the same both before and after (this is not correct).
If I pop back to the rootVC and then push back to the TVC then I can scroll all the way again and see all my new cells.
I did some testing.
If I re-enable autoRotating using - (BOOL)shouldAutorotate then go through the motions of adding the new cells etc then I still can't scroll to the bottom. But if I rotate landscape and then back to portrait then now I can scroll all the way to the bottom.
Off the back of this I tried running the [self viewWillLayoutSubViews]; method after the [self.tableView endUpdates]; but still nothing.
Like I said, I have done this before many times and with no problems. I really don't understand what is happening now.
I finally found a solution that worked!
In the end I had to put [self.tableView reloadData]; into the viewDidAppear method.
That solved the problem.

How to initially select a row in UITableView

I can not find a good spot to call selectRowAtIndexPath:animated:scrollPosition: to initially select a row in UITableView. Table data have not been loaded when the table view controller is initialized, so I can't do selection immediate after the initialization of my UITableViewController(Over bound exception would occur otherwise).
You need to use viewWillAppear: to set the state of a view before it appears, every time it appears, even if the view has already been displayed previously. Any non-visible view in a UITabViewController or UINavigationViewController can be unloaded at any time, so you cannot count on a non-visble view to retain its state.
Or, for finer control, implement loadView, viewDidLoad, and viewDidUnload.
If you are maintaining your own hierarchy of view controllers you will have to manually forward the viewWillAppear, viewWillDisappear, etc., messages to your sub-view controllers.
Try and overload viewWillAppear:animated or viewDidAppear:animated make sure to call super as well.
Make sure to call selectRowAtIndexPath:indexPath animated:NO as well, it will select without the time delay.
you can set any cell selected in cellforrowatindexpath method of uitableview.By using cell.selected=YES;

Resources