2016-03-07 108 views
0

我正在創建一個表視圖應用程序。 當表格視圖中的單元格被觸摸時,我必須顯示一個網頁視圖。 但tableView的導航控制器顯示一個零值。 它不會推送到detailsViewController。 任何人都請幫我解決這個問題。UINavigationController不推送視圖控制器

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

     NewsDetailsViewController *detailsVc=[[NewsDetailsViewController alloc]initWithNibName:@"NewsDetailsViewController" bundle:nil]; 

     NSString *launchURL = [nf.newsStories [indexPath.row] objectForKey:@"link"]; 

     detailsVc.url = launchURL; 

     NSLog(@"View controllers before pushing : %@",self.navigationController.viewControllers); 
     [self.navigationController pushViewController:detailsVc animated:YES]; 
     NSLog(@"View controllers after pushing : %@",self.navigationController.viewControllers); 
    } 

NavigationController Value in debugger

+0

NewsViewerController是從someview目前? – Hardik

回答

0

我想這個問題是與創建您的控制器,該行

NewsDetailsViewController *detailsVc=[[NewsDetailsViewController alloc]initWithNibName:@"NewsDetailsViewController" bundle:nil]; 

嘗試用這一個

NewsDetailsViewController *detailsVc= [[NSBundle mainBundle] loadNibNamed:@"NewsDetailsViewController" 
            owner:self 
            options:nil][0]; 

來取代它無論如何,我勸你轉向使用Storyboard和Segues

相關問題