问题描述
请原谅我在快速搜索之前是否曾问过这个问题,找不到答案。我正在创建一个应用程序,用户可以在其中接收朋友的请求,并且希望用户能够向左滑动以显示接受或拒绝请求的不同选项
如果有帮助,这是我的滚动视图
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)
}
edit:我尝试将水平滚动视图嵌套在垂直滚动视图中,如下所示 ScrollView(.horizontal){ vstack(间距: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),label: {
//Create a chat room card
Button(action: {
detailShowing = true
},label: {
ChatRoomView(room: room)
}).buttonStyle(PlainButtonStyle())
}
).buttonStyle(PlainButtonStyle())
}
})
}.padding(.top,30)
}
但这就是我的结局
解决方法
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
])
}