Hi there,
I've set up a grouped table on my app, and pushing to new views works fine. Except for one thing. The titles and stack layout are all weird. Here's the breakdown:
- I have two sections in my table.
- When I tap on the first row in the first section, it takes me to the correct view, but the title of the new view is the name of the first row in the second section of the table.
- In turn, the second row in the first section's title is the second row in the second section's title.
If I tap on the second row in the second section of the root view table, the navigation button goes to the second row in the first section of the table.
So here's a diagram of my table:
Table Section 1
Row 1
Row 2
Row 3
Table Section 2
Row A
Row B
Row C
So if I tap on row 3, the title of the pushed view is Row C. The navigation button tells me to go back to Row 3, then eventually ending up at the root view.
Here's my implementation file pushing the views:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//CSS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"CSS"])
{
CSSViewController *css = [[CSSViewController alloc] initWithNibName:@"CSSViewController" bundle:nil];
[css setTitle:@"CSS"];
[self.navigationController pushViewController:css animated:YES];
}
//HTML
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"HTML"])
{
HTMLViewController *html = [[HTMLViewController alloc] initWithNibName:@"HTMLViewController" bundle:nil];
[html setTitle:@"HTML"];
[self.navigationController pushViewController:html animated:YES];
}
//JS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"JavaScript"])
{
JSViewController *js = [[JSViewController alloc] initWithNibName:@"JSViewController" bundle:nil];
[js setTitle:@"JavaScript"];
[self.navigationController pushViewController:js animated:YES];
}
//PHP
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"PHP"])
{
PHPViewController *php = [[PHPViewController alloc] initWithNibName:@"PHPViewController" bundle:nil];
[php setTitle:@"PHP"];
[self.navigationController pushViewController:php animated:YES];
}
//SQL
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"SQL"])
{
SQLViewController *sql = [[SQLViewController alloc] initWithNibName:@"SQLViewController" bundle:nil];
[sql setTitle:@"SQL"];
[self.navigationController pushViewController:sql animated:YES];
}
& the array feeding the table's data:
- (void)viewDidLoad {
[super viewDidLoad];
arryClientSide = [[NSArray alloc] initWithObjects:@"CSS",@"HTML",@"JavaScript",nil];
arryServerSide = [[NSArray alloc] initWithObjects:@"Objective-C", @"PHP",@"SQL",nil];
// arryResources = [[NSArray alloc] initWithObjects:@"HTML Colour Codes", @"Useful Resources", @"About",nil];
self.title = @"Select a Language";
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
Any help would be greatly appreciated.
Jack