UInavigation popping back view and updating previous view's content - ios

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?

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

UITableview scrolling to top after popViewControllerAnimated is called

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)

UITableView not loading fully inside UIScrollView

I'm creating a ViewController that will contain as a portion of it a scrollView. In that scrollView I would like to include the view of another ViewController. When I set up this ViewController inside of the ScrollView, all of that ViewController's data is pulled from the web and even it's "ViewDidLoad" method is called. However, nothing appears except for the tableViewLines and a spinner I've created to show the page is loading. Here is what it looks like (the ScrollView in question is under Commitments and Awards):
What should be loaded inside the scrollView is a tableView that looks like this:
It may be that the tableview's delegate/datasource are not set correctly. Could you check whether tableView:numberOfRowsInSection: and tableView:cellForRowAtIndexPath: are called or not?
It is not a good idea to show view of one view controller in another view controller view. Apple does not recommend it. what ever you want to do, do it in the same view controller.

Can't change the size of a TableView in Interface Builder

I'm trying to change the size of a tableView I have in interface builder and can't seem to. When I first started the app I could drag it around and stretch the sides but all of a sudden I can't adjust it. I tried to delete my tableView and add a new one but the same thing happened. Thanks in advance. Here's what I see when I try to change the size:
if your using a UIViewController you can drag and drop a tableView and can place in a custom position you want. but if your using a UITableViewController you cant move the tableView to your custom position. if you want to do it in UITableViewController you can do like below
if you want your tableView content should show from a point, that you want you can do this way,
[self.tableView setContentInset:UIEdgeInsetsMake(100,0,0,0)];
else if you want set your tableView to a frame in UITableViewController you do this way,
- (void) viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.tableView.frame = CGRectMake(0,100,320,300);
}
hope this will help you.
What kind of view controller are you using to manage your table view? Since you show "prototype cells", I'm guessing it's a UITableViewController. Those are built to fill the entire screen with a single table view (which has always annoyed me.)
Starting with iOS 6, though, you can create a "container" view in another view controler, and then drag an embed segue from your container view onto the table view controller. That does all the housekeeping to make the table view controller a child view controller of the other one, and then you can make it whatever size you want.
If you don't want to use a UITableViewController as a child of another view controller, you can use a regular view controller and wire up the data source and delegate methods yourself. However, things like static table views and prototype cells don't work then.
Hopefully this helps someone still coming across this problem. What I did was make sure the UIViewController had a UIView as its direct child, then dragged the UITableView as a child of the UIView, this allowed me to resize the UITableView.

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