---
title: "使用push在两个tableview或者tableviewcell切换"
author: "夜鸣猪"
date: "2013-03-27T10:41:58Z"
tags: []
categories: ["编程语言"]
slug: "push-tableview-tableviewcell"
draft: false
lastmod: "2013-03-27T10:41:58Z"
id: 1837162
url: "https://hlee.iteye.com/blog/1837162"
---

push segue between the view controllers

总之，要把第一个view加NavigationController

方便的可以这样

```java
Editor > Embed In > Navigation Controller
```


也可以：


> NavigationController -> UIViewController (has PageControl, hold multiple pages, horizontally scrollable) -> UITableViewController (represents one list of news for one category), and when user clicks on a single news, gets DetailsViewController (instance of UIViewController).
> 



```c

 if ([[segue identifier] isEqualToString:@"ShowTelegrafDetails"]){
    TelegrafDetailsViewController *details = (TelegrafDetailsViewController*)segue.destinationViewController;

    NSIndexPath *myIndexPath = [self.tableview indexpathforselectedrow];     

    if([self isitpad])
        details.linkFromTableView = [[othernews objectatindex:myindexpath.row] link];
    else
        details.linkFromTableView = [[[myviewcontroller.itemmatrix objectatindex:[self calculatecurrentpage]] objectAtIndex:myIndexPath.row] link];

    NSLog(@"%@",segue.sourceViewController);
    NSLog(@"%@",segue.destinationViewController);

    [self.myviewcontroller.navigationcontroller pushviewcontroller:details animated:yes];
    }

```