导航按钮后退按钮显示相同的viewcontroller

时间:2013-05-05 01:23:51

标签: ios navigation

附件是我创建的单个视图iPhone应用程序的快照。我有一个从事件单元格到第二个屏幕的segue,被邀请者列表。我有另外一个从邀请者到Checkin的segue。因此,当我从Events转到Invitees时,导航按钮会显示Events,这就是我想要的。但是,当我点击Lisa Webb单元格时,在检查时导航按钮显示Lisa Webb。当我点击Lisa Webb导航按钮时,我会看到相同的签到页面,但现在导航按钮显示了事件A,这是我在事件列表中单击的内容。我想在签到页面上显示Invitees而不是Lisa Webb,然后回到Invitees。我无法弄清楚该怎么做。我正在使用导航控制器。

Events

Invitees

Checkin

Checkin after Lisa Webb button is clicked

Segues

以下是从Invitees(2nd)到Checking(3rd)的prepareForSegue代码

#pragma mark - Segue
       -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([[segue identifier] isEqualToString:@"InviteesToCheckIn"]) {
            //UIViewController *inviteesViewController = [segue destinationViewController];
            CheckInViewController *checkInViewController = [segue destinationViewController];
            // In order to manipulate the destination view controller, another check on which table     (search or normal) is displayed is needed
            if(sender == self.searchDisplayController.searchResultsTableView) {
                NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView      indexPathForSelectedRow];
            NSString *destinationTitle = [[filteredInviteesArray objectAtIndex:[indexPath row]] InviteeName];
            NSNumber *selectedInviteeId = [[filteredInviteesArray objectAtIndex:[indexPath row]] InviteeId];
            [checkInViewController setTitle:destinationTitle];
            checkInViewController.inviteeId = selectedInviteeId;
        }
        else {
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
            NSString *destinationTitle = [[theInvitees objectAtIndex:[indexPath row]] InviteeName];
            NSNumber *selectedInviteeId = [[theInvitees objectAtIndex:[indexPath row]] InviteeId];
            [checkInViewController setTitle:destinationTitle];
            checkInViewController.inviteeId = selectedInviteeId;
        }

    }
}

pragma mark - 表视图委托

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */
    [self performSegueWithIdentifier:@"InviteesToCheckIn" sender:tableView];
}

1 个答案:

答案 0 :(得分:0)

如果您想将之前的标题更改为字面意思“被邀请者”,就像您说的那样只需在segue(prepareForSegue方法)之前设置self.title = @“invitees”。然后导航将在下一页显示后退按钮。当您返回时(使用退出segue或pop,您可以将标题设置回事件A或您请求的任何内容。