繁体   English   中英

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

[英]Navigation button back button shows the same viewcontroller

附件是我创建的单视图iPhone应用程序的快照。 我有一个从事件单元格到第二个屏幕(被邀请者列表)的提示。 从受邀者到签到者,我还有另一个话题。 因此,当我从“事件”转到“受邀者”时,导航按钮显示“事件”,这正是我想要的。 但是,当我单击Lisa Webb单元格时,在签入中,导航按钮显示Lisa Webb。 当我单击Lisa Webb导航按钮时,会显示相同的签入页面,但是现在导航按钮显示事件A,这是我在“事件”列表上单击的内容。 我想在签到页面上显示被邀请者而不是Lisa Webb,然后返回到被邀请者。 我不知道该怎么做。 我正在使用导航控制器。

大事记

受邀者

报到

单击Lisa Webb按钮后签入

塞格斯

以下是我为从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;
        }

    }
}

实用标记-表格视图委托

- (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];
}

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM