Troy Barrios
Troy Barrios

Reputation: 177

Trouble displaying modal view

I am trying to call a modal view programmatically however when i click on the view to launch the 2nd view nothing happens. I also included an NSLog to see if it anything was fired. Here is my code

-(void) tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath{
    //NSLog(@"Tapped");
    UIStoryboard * sb = [self storyboard];
    PredictedTimeViewController * pvc = [sb instantiateViewControllerWithIdentifier:@"predictedTime"];
    pvc.routeNumber = self.routeNumber;
    pvc.stopId = self.stopId;
    [self presentViewController:pvc animated:YES completion:nil];

}

Upvotes: 1

Views: 48

Answers (1)

Ríomhaire
Ríomhaire

Reputation: 3114

You need to set the delegate of the UITableView for the didSelectRowAtIndexPath (or didHighlightRowAtIndexPath as you have in the question) method to be called. I would use didSelectRowAtIndexPath to accomplish what you are trying to achieve.

i.e.

in the viewDidLoad method of the current ViewController

self.myTableView.delegate = self; // self.myTableView if it is a property

Upvotes: 1

Related Questions