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];
}
}
你已經添加在故事板一賽格瑞呢? –
不要在這種情況下使用segue,分開使用它們,並正常推送。你可以很容易地從storyboard中實例化一個ViewController而不使用segue,但是使用storyboard標識符。 – iphonic
此外,你的代碼看起來很可怕(看上去)。不要使用'[]'來訪問屬性(比如'[indexPath row]',而是使用點符號)。 –