Call UIViewController from "subview"
I have a UIViewController that loads this on load.
MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil];
self.mapViewController = mapController;
[self.view insertSubview:mapController.view atIndex:0];
[mapController release];
I also have a radio button view button that can change in a table view ...
if (self.tableViewController ==nil)
{
TableViewController *tableController = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil];
self.tableViewController = tableController;
[tableController release];
//[self.view insertSubview:detailController atIndex:0];
}
if (self.mapViewController.view.superview == nil)
{
[tableViewController.view removeFromSuperview];
[self.view insertSubview:mapViewController.view atIndex:0];
}
else
{
[mapViewController.view removeFromSuperview];
[self.view insertSubview:tableViewController.view atIndex:0];
}
I'm trying to change the view to a detailed view based on a row selection in a table view and I can't figure out how to call it at all. All the methods I seem to fail! Please, help!
+1
a source to share
2 answers
Add the UITableViewDelegate protocol to the controller class.
@interface myTableViewController : UITableViewController <UITableViewDelegate>
When you create your veiw table controller, its delegate should be your controller using:
myTableViewController.delegate = self; // Assuming your setup code runs within the table view controller
Your TableViewController implements didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int rowSelected = [indexPath indexAtPosition:0]; // Assuming your UITableView has a single section.
0
a source to share