Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 持有观点';弹出另一个视图后要返回的状态_Ios_Uinavigationcontroller_Navigationcontroller - Fatal编程技术网

Ios 持有观点';弹出另一个视图后要返回的状态

Ios 持有观点';弹出另一个视图后要返回的状态,ios,uinavigationcontroller,navigationcontroller,Ios,Uinavigationcontroller,Navigationcontroller,我有一个搜索视图控制器,当最初点击搜索栏时,它处于初始状态。搜索后,您处于同一控制器中,但现在列出了结果。如果单击任何一行,您将进入一个完全不同的视图,但单击“上一步”按钮时,您将进入初始搜索视图,而不是搜索结果。有没有办法保存搜索结果状态,以便我可以返回用户的搜索 这是用于加载所选搜索结果的代码 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if

我有一个搜索视图控制器,当最初点击搜索栏时,它处于初始状态。搜索后,您处于同一控制器中,但现在列出了结果。如果单击任何一行,您将进入一个完全不同的视图,但单击“上一步”按钮时,您将进入初始搜索视图,而不是搜索结果。有没有办法保存搜索结果状态,以便我可以返回用户的搜索

这是用于加载所选搜索结果的代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.editing)
    {
        return;
    }

    ResultViewController * vc = [self resultViewControllerForIndex: [self.dataController indexForIndexPath:indexPath]];
    vc.title = [self titleForDetailsView];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController: vc animated: YES];

    _selectedCouponGuid = vc.result.guid;
}
这些都是我试图恢复这种观点的不同方式

//- (UIViewController *)backViewController {
- (void)backViewController {

    // attempt 1 -- crash
//    [self.navigationController pushViewController:self.navigationController.parentViewController animated:NO];

    // attempt 2 -- back to store listing
//    [self.navigationController popViewControllerAnimated:NO];

    // attempt 3 -- doesn't do anything
//    return self.presentingViewController;

    // attempt 4 -- back to discover screen, reload initial search tableview
//    [self.navigationController popToRootViewControllerAnimated:YES];

    // attempt 5 -- doesn't do anything
//    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

    // attempt 6
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:3] animated:YES];
}
这里是VCs进入结果并点击后退按钮退出所选结果视图

选择行

List of VCs: (
    "<HomeViewController: 0x7fbc8ebb8200>",
    "<ExploreViewController: 0x7fbc8e883a00>",
    "<SearchViewController: 0x7fbc8c005000>",
    "<ResultViewController: 0x7fbc8c1e7400>"

你是否重新加载ViewWillDisplay中的任何数据?我刚刚为结果VC添加了加载方法,但现在我想你建议我在搜索VC中添加一些内容,以检查一些字符串,如果他们已经搜索过,那么将加载这些字符串。为什么不使用更简单的
performsgue
unwindSegue
解决方案呢你需要一个故事板来完成一段。我们在这个项目中没有任何故事板。
List of VCs: (
   "<HomeViewController: 0x7fa519279c00>",
   "<ExploreViewController: 0x7fa51b806600>",
   "<SearchViewController: 0x7fa51b882800>",
   "<ResultViewController: 0x7fa51b0fea00>"
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.titleView = [[UIView alloc] init];


    [self putStandardNavBarButtons: NO];

    _tableView = [[FancyTableView alloc] initWithFrame: self.view.bounds style: UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollIndicatorInsets = UIEdgeInsetsMake(20, 0, 0, 0);
    _tableView.backgroundColor = [Styling defaultBackgroundColor];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview: _tableView];

    _DetailsHeaderView = [[CouponDetailsHeaderView alloc] initWithFrame: CGRectMake(0, 0, self.view.width, 0)];
    _DetailsHeaderView.delegate = self;
    [self updateViewsForCoupon];


    _releaseToViewImageLabel = [[UILabel alloc] initWithFrame: CGRectZero];
    _releaseToViewImageLabel.backgroundColor = [UIColor clearColor];
    _releaseToViewImageLabel.textColor = [UIColor whiteColor];
    _releaseToViewImageLabel.font = [Styling semiBoldFontOfSize: 14.0f];
    _releaseToViewImageLabel.textAlignment = NSTextAlignmentCenter;
    _releaseToViewImageLabel.text = @"Release to view image";
    [self.view addSubview: _releaseToViewImageLabel];

    [self reloadDetails];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear: animated];

    [UIView animateWithDuration: 0.3 delay: 0 options: UIViewAnimationOptionBeginFromCurrentState animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
    } completion:^(BOOL finished) {

    }];

    [ExternalAnalytics trackViewForCoupon:self.coupon];

    if (self.redeemOnAppear)
    {
        self.redeemOnAppear = NO;
        [self showRedeemScreen];
    }
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    [self.view fillSuperView];

    [_tableView fillSuperView];

    [_releaseToViewImageLabel fillWidthOfSuperView];
    _releaseToViewImageLabel.height = 30;
    [self updateReleaseLabelPosition];
}