0

如果在我快速搜索找不到答案之前有人问过这个问题,请原谅我。我正在创建一个应用程序,用户可以在其中接收好友请求,并且我希望用户能够向左滑动以显示不同的选项来接受或拒绝请求

为了更清楚,这就是我想要的样子 在此处输入图像描述 在此处输入图像描述

如果有帮助,这是我的滚动视图

 ScrollView(.vertical){
                        VStack(spacing: 40){
                            
                            // TODO Add Chat Rooms
                            ForEach(ChatRooms, content: {room in
                                //Create an in app link that navigates to messaging screen
                                NavigationLink(
                                    destination: MessageDetail(messageShowing: $detailShowing),
                                    isActive: $detailShowing,
                                    label: {
                                        //Create a chat room card
                                        Button(action: {
                                            detailShowing = true
                                        }, label: {
                                            ChatRoomView(room: room)
                                        }).buttonStyle(PlainButtonStyle())
                                        
                                    }
                                    
                                ).buttonStyle(PlainButtonStyle())
                            
                        })
                        
                    }.padding(.top, 30)
                }

编辑:我尝试在我的垂直滚动视图中嵌套一个水平滚动视图,如下所示 ScrollView (.horizo​​ntal) { VStack(spacing: 40){

                                // TODO Add Chat Rooms
                                ForEach(ChatRooms, content: {room in
                                    //Create an in app link that navigates to messaging screen
                                    ScrollView (.horizontal) {
                                        NavigationLink(
                                            destination: MessageDetail(messageShowing: $detailShowing),
                                            isActive: $detailShowing,
                                            label: {
                                                //Create a chat room card
                                                Button(action: {
                                                    detailShowing = true
                                                }, label: {
                                                    ChatRoomView(room: room)
                                                }).buttonStyle(PlainButtonStyle())

                                            }

                                        ).buttonStyle(PlainButtonStyle())
                                    }



                                })

                           }.padding(.top, 30)
                        }

但这就是我的结局

在此处输入图像描述

4

1 回答 1

0

try this class :-

https://github.com/EnesKaraosman/SwipeCell

how to use:-

Simply add onSwipe(leading, trailing) method to your list item
    List {
        HStack {
            Text("Enes Karaosman")
            Spacer()
        }
        .listRowInsets(EdgeInsets())
        .onSwipe(leading: [
          .. // here add slots
        ])
        
    }
于 2020-10-05T06:37:26.720 回答