Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with self.navigationController and pushViewController
    primarykey
    data
    text
    <p>I am having trouble pushing from a tableview to a detail view. When I click the tableview cell, the cell highlights but does not push to the detail view. I am using this to transition to the detail view:</p> <pre><code>[self.navigationController pushViewController:detailViewController animated:YES]; </code></pre> <p>I have read that this is a common issue, but am somehow unable to figure out a solution. My full .m file is below. If anyone has any recommendations that would be amazing. Thank you!</p> <pre><code>#import "ViewController.h" #import "DetailViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @"title"; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; NSURL *url = [NSURL URLWithString:@"http://website.com/json.php"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; // Do any additional setup after loading the view, typically from a nib. } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; news = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil]; [mainTableView reloadData]; } - (int)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [news count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"]; if(cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MainCell"]; } cell.textLabel.text = textForMyLabel; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"Back" style: UIBarButtonItemStyleBordered target: nil action: nil]; [[self navigationItem] setBackBarButtonItem: newBackButton]; DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; detailViewController.title = [[news objectAtIndex:indexPath.row] objectForKey:@"name"]; detailViewController.newsArticle = [news objectAtIndex:indexPath.row]; [self.navigationController pushViewController:detailViewController animated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload