【发布时间】:2016-03-26 11:44:18
【问题描述】:
这可能是一个微不足道的问题,但我还没有找到解决方案。我正在使用 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 中,您可以通过创建意图来启动一个新 Activity 以获得所需的行为,但它在 Iphone 上是如何工作的?
我的问题是我希望能够在调用navigationController.popViewControllerAnimated 时直接返回。这只是一个玩具示例,用于了解它是如何工作的,以便我以后可以在 if 子句中使用它。
【问题讨论】:
-
你想做什么? navigationController?.popViewControllerAnimated(true) 会让你回到上一个视图
-
你要做什么,popViewController 会带你回去,但是下面的代码是什么?你有什么问题,你有什么问题?
标签: ios iphone swift popviewcontrolleranimated