这一切可能是一个微不足道的问题,但我还没有找到解决方案。我正在使用 Swift 为 Iphone 制作一个应用程序。
我有一个带有一些字符串的表格视图,如果我按下一个按钮,我想直接导航回上一个视图。但是,我打电话后的代码
navigationController?.popViewControllerAnimated(true)
始终运行,但我希望当前活动停止并返回上一个视图。
代码如下所示:
@IBAction func DeletePressed(sender: UIButton) {
let deleteIndices = getIndexToDelete()
navigationController?.popViewControllerAnimated(true)
print("After navigationController")
for index in deleteIndices{
results?.ListResults[yearShownIndex].months[monthShownIndex].day[dayShownIndex].results.removeAtIndex(index)
}
if (results?.ListResults[yearShownIndex].months[monthShownIndex].day[dayShownIndex].results.count == 0){
results?.ListResults[yearShownIndex].months[monthShownIndex].day.removeAtIndex(dayShownIndex)
}
if (results?.ListResults[yearShownIndex].months[monthShownIndex].day.count == 0){
results?.ListResults[yearShownIndex].months.removeAtIndex(monthShownIndex)
}
if (results?.ListResults[yearShownIndex].months.count == 0){
results?.ListResults.removeAtIndex(monthShownIndex)
}
loadView()
}
始终显示“导航控制器之后”。
在 android 中,您将通过创建意图来启动新活动以获得所需的行为,但它如何在 Iphone 上工作?
我的问题是我希望能够在navigationController.popViewControllerAnimated
被调用时直接返回。这只是一个玩具示例,用于了解它是如何工作的,以便我以后可以在 if 子句中使用它。