如何清除导航堆栈,以便不显示后退按钮?

时间:2016-11-28 19:20:03

标签: ios swift uinavigationcontroller swift2 uinavigationbar

这就是我的视图控制器在故事板中的结构:

    $friend_status = 2;
    $friend_sql = "
        SELECT *
        FROM friends
        WHERE friend_one or friend_two = ?
        AND status = ?
    ";
    $friend_stmt = $con->prepare($friend_sql);
    $friend_stmt->execute(array($user_id, $friend_status));
    $friend_total_rows = $friend_stmt->fetchAll(PDO::FETCH_ASSOC);
    $count_total_friend = $friend_stmt->rowCount();
    foreach ($friend_total_rows as $friend_total_row) {
        //$select_friend_1  = $friend_total_row['friend_one'];
        //$select_friend_2  = $friend_total_row['friend_two'];
        //$friend_status        = $friend_total_row['status'];
        //$friend_status_date = $friend_total_row['date'];
    }

我有一个从navController1 -> viewController1 -> viewController2 -> viewController3 回到viewController3的segue。因此,当用户转换为viewController1时,后退按钮会显示在导航栏上(如预期的那样)。但是,在我的情况下,我不希望用户从viewContoller1返回viewController3。我想再次从viewController1重新开始。转换到viewController1后是否有办法清除堆栈,以便不显示后退按钮?

(请注意,navController1不是我的根控制器,我之前有一些其他控制器。)

1 个答案:

答案 0 :(得分:0)

您有navigationController成员。它实际上是推入控制器的堆栈。清除堆栈,你应该得到你想要的结果。为此,在上一个View Controller中为navigationController?.viewControllers设置一个空列表。希望这能帮助您找到解决方案。