In my app, I need to load a different view for each cell in my table view when it is pressed. I have tried the code below, but my app fails when the cell is pressed.
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell.textLabel.text == @"Area")
{
ThirdViewController *tvController = [[ThirdViewController alloc] initWithNibName:@"ThirdView" bundle:nil];
[self.navigationController pushViewController:tvController animated:YES];
}
}
note that I have imported the ‘thirdviewcontroller.h’ file in the implementation file that code is in.
I am still getting used to coding with obj-c and Xcode, so please excuse me if I’ve tried something completely dumb/stupid. If you need more information, please let me know, so that my question is not closed.
I have also searched around, but nothing I have found seems to be helpful to me.
Thanks
You might wanna add a modalviewcontroller based on what cell you clicked on.
You know u have populated the tableview with an array, yes?
Well do something like this:
This will make a new viewcontroller appear based on the selection you made.