Search code examples
iosuitableviewxcode5

Segue from Table View Cell xib with disclosure Indicator to storyboard


I am new in iOS programing and I have an issue. I have a customized table view cell with disclosure indicator in a separate xib file and I want to call a viewcontroller which is in storyboard when the user taps the cell.

Here is the customized table view cell :

http://i62.tinypic.com/2qx6w3q.jpg

Here are the table view (class : TableViewController) that displays the custom table cell and the view (class : ViewController) I want to call when the user taps the customized table view cell :

enter image description here

Does the view I want to call have to be in a separate xib file or can I let it in my storyboard? What is the best solution?


Solution

  • Just use didSelectRoWAtIndexPath method of table view …DO something like this..

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        NSString* viewType = @"YourVCIdentifier";//u can have ContactVC or NavC as other options depending on ur condition
        UIViewController* viewController = [storyboard instantiateViewControllerWithIdentifier:viewType];
    
        [self.navigationController pushViewController:viewController animated:YES];
    
    
    }
    

    that will do it