我目前有一个 tableview,由于某种原因正在产生双重 segue 连接。
[home] -> [ subview #2] -> [同一个 subview #3]
当我点击一行时,它会通过这些将我发送到第三个 View [#3]。这是正确的 View 信息,但我只想走一步 [#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];
}
}
最佳答案
正如 iphonic
所说,没有理由仅仅为了使用 segues 而做所有这些开销。
您可以只编辑didSelect
方法并自己推送 View Controller 。
- (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];
}
}
关于ios - 双Segue IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24859167/