【问题标题】:SwiftUI 4: ShareLink as a swipe actionSwiftUI 4:ShareLink 作为滑动操作
【发布时间】:2022-11-19 14:21:38
【问题描述】:

当用户与滑动操作交互时,我想呈现一个共享表。 为了实现这一点,我目前只有这段代码:

            .swipeActions(edge: .leading, allowsFullSwipe: false) {
                ShareLink("Text", item: "Text")
                    .tint(.accentColor)
            }

它看起来像这样:

但是当我点击它时,没有任何反应......

我真的很感激任何帮助!

【问题讨论】:

    标签: xcode swiftui swiftui-list ios-sharesheet


    【解决方案1】:

    一张股票单

    struct SheetView: View {
    
       @Binding var showSheetView: Bool
        @State private var isShare = false
       var body: some View {
    
    
          // Below share Sheet - now works!
          Button(action: {
                isShare = true    // present activity
          }) {
            Text("Share Me")
          }
          .background(SharingViewController(isPresenting: $isShare) {
             let url = URL(string: "https://apple.com")
             let av = UIActivityViewController(activityItems: [url!], applicationActivities: nil)
             av.completionWithItemsHandler = { _, _, _, _ in
                    isShare = false // required for re-open !!!
                }
                return av
            })
       }
    }
    
    

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      • 1970-01-01
      • 1970-01-01
      • 2020-04-10
      • 2022-11-15
      相关资源
      最近更新 更多