首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >附加.simultaneousGesture时,SwiftUI文本字段会停止触发NavigationLink的事件

附加.simultaneousGesture时,SwiftUI文本字段会停止触发NavigationLink的事件
EN

Stack Overflow用户
提问于 2019-11-05 05:44:42
回答 2查看 596关注 0票数 1

我有以下NavigationLink:

代码语言:javascript
运行
复制
NavigationLink(destination:
         TrendSlider(
            title: .constant(title),
             col: .constant(self.dataModel.queryColumnSeasonWinPercentageTeam1),
             opIndx: self.$dataModel.seasonWinPercentageTeam1OperatorIndxValue,
             val: self.$dataModel.seasonWinPercentageTeam1SliderValue,
             lBound: .constant(self.dataModel.seasonWinPercentageTeam1Values.first!) ,
             uBound: .constant(self.dataModel.seasonWinPercentageTeam1Values.last!),
             lRange: self.$dataModel.seasonWinPercentageTeam1RangeSliderLowerValue ,
             uRange: self.$dataModel.seasonWinPercentageTeam1RangeSliderUpperValue,
             step: .constant(1.0),
             displayReadableQuery: $readableQuery

   )) {
       HStack {
          if readableQuery.hasSuffix("IS ANY") {
                Text(title)
                Spacer()
                Text("IS ANY").foregroundColor(Color("TPLightGrey"))
            }else{
                Text(readableQuery).foregroundColor(Color("TPOrange"))

            }
       }
   }.simultaneousGesture(TapGesture().onEnded{
       sendViewSelectionEvent(name: self.title, referral: "Game")

   })

如果我在".simultaneousGesture...“中离开,那么点击文本元素不会触发NavigationLink操作,但是行的其余部分可以工作。

如果删除.simultaneousGesture,则可以再次在任何位置点击该行。

虫子?

EN

Stack Overflow用户

发布于 2019-11-05 23:39:24

谢谢你的解释。这不足为奇。这促使我寻找一种合适的方式来触发我的呼叫。

代码语言:javascript
运行
复制
.onAppear(){ .... }

我试图在navlink上模拟一个viewWillAppear类型的事件。我把onAppear放在vStack上,它工作得很好。

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58701514

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档