これはおそらく些細な質問ですが、解決策は見つかりませんでした。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()
}
「After navigationController」は常に表示されます。
Android では、目的の動作を取得するためのインテントを作成して新しいアクティビティを開始しますが、Iphone ではどのように機能するのでしょうか?
私の問題は、呼び出されたときに直接戻ることができるようにしたいということですnavigationController.popViewControllerAnimated
。これは、後で if 句で使用できるように、どのように機能するかを理解するためのおもちゃの例にすぎません。