2014-07-21 34 views
0

我目前有一个tableview,由于某种原因正在产生双重连接。Double Segue IOS

[首页] - > [副视点#2] - > [相同副视点#3]

当我点击发送我通过这些第三视图中的行[#3]。这是正确的视图信息,但我只想走一步[#2]。当我点击回到[#2]而不是回家时,问题就变得很重要。

了在此设置[#2] ==澄清[#3]

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow]; 
    NSInteger row = myIndexPath.row; 
    if ([segue.identifier isEqualToString:@"ShowLocationsTableView"]) 
    { 
     NSLog(@"PREPARE"); 
     LocationsTableViewController *ViewController = segue.destinationViewController; 

     ViewController.categoryDetailModel = @[_categoryTitle[row], _categoryImages[row]]; 
    } 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
if (tableView == self.tableView) { 
    // I assume you have 1 section 
    NSLog(@"DIDSELECTROW"); 
    NSLog(@"INDEX PATH %i", indexPath.row + 1); 
    NSLog(@"%i", [tableView numberOfRowsInSection:0]); 
    if (indexPath.row + 1 == [tableView numberOfRowsInSection:0]) { 
     NSLog(@"ABOUT"); 
     [self performSegueWithIdentifier:@"aboutCat" sender:self]; 
    } else { 
     NSLog(@"ELSE"); 
     [self performSegueWithIdentifier:@"ShowLocationsTableView" sender:self]; 
    } 
} 
+1

你已经添加在故事板一赛格瑞呢? –

+0

不要在这种情况下使用segue,分开使用它们,并正常推送。你可以很容易地从storyboard中实例化一个ViewController而不使用segue,但是使用storyboard标识符。 – iphonic

+0

此外,你的代码看起来很可怕(看上去)。不要使用'[]'来访问属性(比如'[indexPath row]',而是使用点符号)。 –

回答

3

正如iphonic说,没有理由要尽一切开销只是使用塞格斯。

您可以编辑didSelect方法并自己推送视图控制器。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (tableView == self.tableView) { 
     UIViewController *viewController = nil; 
     if (indexPath.row == [tableView numberOfRowsInSection:0] - 1) { 
      viewController = [self.storyboard instantiateViewControllerWithIdentifier:<#Identifier#>]; 
      //Do any setup needed by casting your viewController. 
     } else { 
      viewController = [self.storyboard instantiateViewControllerWithIdentifier:<#Identifier#>]; 
       //Do any setup needed by casting your viewController. 
     } 
     [self.navigationController pushViewController:viewController]; 
    } 
} 
0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (tableView == self.tableView) 
    { 
    UIViewController *viewController = nil; 
    if (indexPath.row == [tableView numberOfRowsInSection:0] - 1) { 
     viewController = [self.storyboard instantiateViewControllerWithIdentifier:<#Identifier#>]; 
     //Do any setup needed by casting your viewController... 
    } else { 
     viewController = [self.storyboard instantiateViewControllerWithIdentifier:<#Identifier#>]; 
      //Do any setup needed by casting your viewController... 
    } 
    [self.navigationController pushViewController:viewController]; 
    } 
}