【发布时间】:2013-05-05 01:23:50
【问题描述】:
附件是我创建的单视图 iPhone 应用程序的快照。我有一个从事件单元到第二个屏幕,即受邀者列表的转场。我有另一个从 Invitees 到 Checkin 的 segue。因此,当我从“事件”转到“受邀者”时,导航按钮会显示“事件”,这正是我想要的。但是,当我单击 Lisa Webb 单元格时,在签入时,导航按钮会显示 Lisa Webb。当我单击 Lisa Webb 导航按钮时,我会看到相同的签到页面,但现在导航按钮显示事件 A,这是我在事件列表上单击的。我想在签到页面上显示受邀者而不是 Lisa Webb,然后返回受邀者。我不知道该怎么做。我正在使用导航控制器。
下面是我的prepareForSegue代码,从Invitees(2nd)到Checking(3rd)
#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];
}
【问题讨论】:
-
很难从您的描述中看出发生了什么——您需要更全面地描述您在 IB 中设置的内容。如果您可以发布一张显示您的 segues 的图片,那就太好了。
-
我已将图像添加到 segues(第 5 张图片)
-
我仍然对发生的事情感到困惑。你是说当你在 CheckInViewController 中(标题为 Lisa Webb 和返回按钮 Lisa Webb),然后你点击返回按钮,它会带你到另一个 CheckInViewController 场景,标题是 Lisa Webb,后面是 Event A按钮?
-
是的,这就是现在正在发生的事情。我想要做的是当我从被邀请者(第 2 次)转到检查(第 3 次)时,我希望导航 btn 显示被邀请者,并且标题显示我单击的“LIsa Web”(或任何一个)名称。现在,当我单击受邀者上的名称时,我看到 Lisa Webb 作为导航和标题中的文本。当我点击 Lisa webb back btn 时,我看到另一个 CheckIn 但这次我看到 Event A 作为导航 btn 中的文本
-
您似乎有 2 个问题。您将标题设置为 InviteeName。只是不要那样做。你应该给每个控制器你想要的标题,比如第二个控制器的 Invitees,然后不要在 CheckInController 中做任何事情来设置标题。但是从您所展示的内容来看,没有意义的是单击 CheckInController 中的后退按钮如何将您带到另一个 CheckInController。您是在代码中执行任何推送、弹出等操作,还是仅使用您显示的 segues 进行导航?
标签: ios navigation