1

当我使用NavigationLink返回时,它显示上述错误消息。这个错误信息是什么意思?我找不到任何关于这个问题的文章。当它崩溃时,它把我带到@UIApplicationMain 类 AppDelegate: UIResponder, UIApplicationDelegate 并显示这个词“线程 1: EXC_BAD_ACCESS (code=2, address=0x7ffee86aafd8)”。由于我只是导航到一个简单的视图,并且在按下时仍然崩溃。使用 tabView 到另一个视图很好。我认为这是 navigationLink 问题。演示:https ://youtu.be/g8-t0m-0xkU

在我将所有提取按钮代码放入 SelectPlayerView 后,它可以很好地工作。所以我认为我的 goToSelectStartingLineupButton 有什么问题...

struct SelectPlayerView: View {
    @EnvironmentObject var teamResult : TeamResult
    @ObservedObject var allPlayerList : PlayersGameData = PlayersGameData()

    //
    var body: some View {

            goToSelectStartingLineupButton(allPlayerList: allPlayerList)

        }.onAppear(perform: getTeamMemberResults)
            .onDisappear(perform: clearTeamMemberResults)

    }

    struct goToSelectStartingLineupButton: View {
    @ObservedObject var allPlayerList : PlayersGameData
    @EnvironmentObject var teamResult: TeamResult
    @State var goToNextPage : Bool = false

    var selectedPlayerList : PlayersGameData = PlayersGameData()

    var body: some View {

        VStack (spacing: 10){

            Button(action: {
                self.goToNextPage.toggle()
                  for i in 0 ..< self.allPlayerList.playersGameDataArray.count{
                      if(self.allPlayerList.playersGameDataArray[i].isPlayer){

        self.selectedPlayerList.playersGameDataArray.append(self.allPlayerList.playersGameDataArray[i])

                      }

                  }
            }){
                Image(systemName: "arrowshape.turn.up.right.circle"

                Text("\(self.teamResult.groupID) name:\(self.teamResult.groupName)")

            }
            NavigationLink(destination: SelectStartingLineupView(selectedPlayerList: 
      self.selectedPlayerList).environmentObject(teamResult),isActive: $goToNextPage){
                EmptyView()
            }


            }.animation(.spring())
    }

}

我要导航到的课程如下

struct SelectStartingLineupView: View {
@ObservedObject var selectedPlayerList : PlayersGameData
var body: some View {

        VStack {
            List(selectedPlayerList.playersGameDataArray){
                (player) in
                SelectPlayerCellView(player: player)

                }


        }
}
}

错误信息:

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000021ea0d0 'assistantView.bottom' TUISystemInputAssistantView:0x7f865370ed40.bottom == _UIKBCompatInputView:0x7f865341fa90.top   (active)>
4

0 回答 0