UITableViewController not re-firing when using outside modal controller to input data - iphone

I have a UITableViewController that allows for adding to it's cells through another TableviewController where the user can enter their data. I am passing the NSString data back to the first TableViewController properly as the NSLog states. However, the first TableViewController is not re-firing. I believe this is caused because I am using a modal transition. Would somebody explain to me how to make a UITableViewController re-fire with modal transitions?

in
-(void)viewWillAppear:(BOOL)animated
after adding to the table input array(datasource )
call
[tableView reloadData];

Related

Calling addSubview after removeFromSuperview

I am working on a simple UI, but am running into trouble with addSubview calls made after a removeFromSuperview.
In my viewController I have an IBOutlet UITableView
#property (strong, nonatomic) IBOutlet UITableView *tableView;
Depending on the state of the data, I remove the tableview from my viewControllers view.
[self.tableView removeFromSuperview];
So far so good, the view is removed. When using the debugger, I can still see that my viewController has a valid handle to the tableview. The problem starts on the next line when I call addSubview.
[self.view addSubview:self.tableView];
[self.tableView setDataSource:studyResult];
[self.tableView reloadData];
It seems to do nothing and I can't see any change in the UI. I have tried to set the frame on the tableView and still no results.
Have any of you seen this behavior?
Joe
Hi Joe can you give me more code for see what are you going? what I get, is that you have your control and a tableview view inside that you want to shot just when you have your array with the data? if is like that why you don't set Hide the tableview when you haven't the data? every time that you refresh the data for the table you have also to use the method reloadData for refresh the table
Depending on the state of the data, I remove the tableview from my viewControllers view.
Consider segueing to another view controller with a table view instead of swapping out table views in a single view controller. Or, if the new data is a subset of the old data, then leave the table view in place and filter its data.

How to pass selected uitableviewcell variable to previous viewcontroller?

This is the first time I have tried to do this and I understand the concept of what I am trying to do but just not 100% sure on how to execute it.
I have a main view and a sub view.. the main view has several custom uitableviewcells each with a single textlabel. when the cell is selected it loads the subview onto the navigational stack, their is a list of standard uitableviews that I have loaded with values from the database.
When you select one of these uitableviewcells in the sub view, I want to capture that value pop the current view from the stack and then load the selected value of the subview into the main tableviews cell that was originally selected..
In the sub view I am thinking something along the lines of
MainViewController *mvc = [[MainViewController alloc] initWithNibName:#"MainViewController" objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:mvc animated:YES];
[mvc release];
But this obviously this isnt passing any values around...
You want to use delegation, if you don't know how to use it, this link might help:
http://cocoadevcentral.com/articles/000075.php
So the general idea is that your main view will be the delegate of your subview, and the subview will tell it's delegate when a cell was tapped and pass in that variable (for example: [delegate cellChanged:cell];), then the main view (the delegate of the subview) will handle that.

How to hookup a UITableview when it is part of of a UIView

I have a UIViewController that has a UITableView sitting on a UIView that is hidden. I have created a data view object and implmented the data methods and hooked it up in the Interfaced builder as a datasource. I can get the table to show but not populate. I have tried creating a UITableViewControler and adding that the the UIViewController and that did not work.
What am I missing?
If your connections are good, maybe the tableview loads before the data is there. Try
[tableview reloadData];
If that doesn't work, you have bad connections. You can always set the delegate and datasource outside IB.
[tableView setDelegate:uitableviewdelegate]
[tableView setDataSource:uitableviewdatasource]

uitableview delegate methods are not called

I've got the problem that tableview methods are not called the first time the tableview is shown.
If I switch back to the previous view, and then click the button to show the tableview again, the methods are called this time.
I should say that I show an actionsheet while the tableview is loading.
The actionsheet I call in the ViewWillAppear method.
i fixed it by adding [self.tableView reloadData] after dismissing the actionsheet. i don't know if it's the proper way, but it somehow works.

Issue with deselectRowAtIndexPath in tableView

I have a cell with a few lines of text which changes colour when selected/highlighted. The problem is that as the new viewController is being pushed, the deselection animation occurs which is visually distracting as the text suddenly reverts to the unselected state. I have moved the deselectRowAtIndexPath statement after the line where the new view controller is pushed, but this has no effect.
How can I prevent the user seeing the cell deselection (without implementing a timer)? Any help would be appreciated please.
If you're using a UITableViewController, you won't need to call deselectRowAtIndexPath:. This will be done for you automatically when your table view becomes visible again.
If you're not using a UITableViewController because you have a more complicated interface, you would need to call deselectRowAtIndexPath: manually from the viewWillAppear:animated: method.
I think the general paradigm used with table views and pushing new VCs is that you deselect the table row in your viewWillAppear:animated method. Then as the VC is popped, they see which row had been used to navigate to that VC.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];
}
so remove deselectRow from your didSelectRowAtIndexPath method.