【问题标题】:Can I add some action when I push the Navigation back button in SwiftUI?当我在 SwiftUI 中按下导航返回按钮时,我可以添加一些操作吗?
【发布时间】:2020-01-25 18:58:44
【问题描述】:

我正在开发我的第一个 ios 应用程序。

我正在使用 Xcode 11.3 和 Swift5

我不确定这是否可行,我可以在 NavigationLink 中按下后退按钮时添加一个操作吗?

(In this picture, the back button is 'Bibles' button.)

NavigationLink(destination: VerseList(bible: self.bible, chapter: c.chapter)){
               ChapterRow(chapter: c.chapter)
            }.navigationBarTitle("Chapters")

这是我的代码。我想添加“动作”..

有没有更好的方法?

【问题讨论】:

    标签: ios swift xcode swiftui


    【解决方案1】:

    我觉得这样的可能性更大。

    NavigationLink(destination:VerseList(bible: self.bible, chapter: c.chapter)
                       .onDisappear {
                           // put action here
                       }
                  ){ChapterRow(chapter: c.chapter)}
    .navigationBarTitle("Chapters")
    

    【讨论】:

      猜你喜欢
      • 2012-11-07
      • 1970-01-01
      • 2016-05-01
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多