これはおそらく些細な質問ですが、解決策が見つかりませんでした。私はSwiftを使ってiPhone用アプリを作っています。NavigationViewControllerでビューを変更する
私はいくつかの文字列を持つテーブルビューを持っています。私がボタンを押すと、直前のビューに直接移動したいと思っています。しかし、私のコール
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()
}
"navigationControllerをした後、" 常に表示されます。
コードは次のようになります。
アンドロイドでは、目的の動作を得るためにインテントを作成して新しいアクティビティを開始しますが、それはどのようにIphoneで動作しますか?
私の問題は、navigationController.popViewControllerAnimated
が呼び出されたときに直接戻ることができるようにしたいということです。これは、if節で後で使用できるように動作する方法を理解するためのおもちゃの例です。
何をしますか? navigationController?.popViewControllerAnimated(true)を押すと、前のビューに戻ります – Roee84
何をしたいのですか?popViewControllerはあなたを元に戻しますが、その下のコードは何ですか?あなたの問題は何ですか? –