SwiftUI - Swipe Actions on List | iOS 15 & Xcode 13

  Рет қаралды 13,140

Sean Allen

Sean Allen

Күн бұрын

Head to squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
In today's video I show you how to use the new swipe actions introduced in iOS 15 in SwiftUI. Adding a leading or trailing swipe action to a list in SwiftUI has now been made relatively easy with the new .swipeActions modifier. In this video, I demonstrate how to create them from both the leading and trailing sides, disable full-swipe functionality as well as customize the color of the button.
This tutorial was created in Xcode 13 (Beta 1) and Swift 5.5.
Note: These swipe actions require iOS 15 support, so you may need to download Xcode 13 beta (if it's not officially released yet).
SF Symbols Video:
• What's New in SFSymbol...
If you like my teaching or presentation style, I've started creating my own courses:
seanallen.teachable.com/
Timestamps:
0:00 - Important Details
0:45 - Basic Syntax
2:34 - Some "Gotchyas" to Watch Out For
4:19 - Button Role - Destructive
5:00 - Multiple Swipe Actions
5:36 - Parameter Default Values
6:03 - Leading Edge Swipe Actions
Twitter:
/ seanallen_dev
Link to my book - How I Became an iOS Developer:
gumroad.com/l/sean-allen-origin
Hired.com:
hired.com/x/1n01g
Check out my podcast, iOS Dev Discussions:
itunes.apple.com/us/podcast/i...
Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
Ray Wenderlich Books:
store.raywenderlich.com/a/208...
Ray Wenderlich Videos:
store.raywenderlich.com/a/208...
Paul Hudson's Hacking With Swift:
gumroad.com/a/762098803
Learn Advanced Swift Here:
gumroad.com/a/656585843
Links to my iOS Dev Setup & iOS Dev Book Recommendations
www.amazon.com/shop/seanallen
#swift #softwaredeveloper #iosdeveloper

Пікірлер: 31
@Alejandro_Away
@Alejandro_Away 3 жыл бұрын
What worked for me was having .swipeActions modifier be for the NavigationLink inside a ForEach which is inside a List view
@KimbrellBrad
@KimbrellBrad 3 жыл бұрын
Great notes on the current hurdles to making these swipe actions work. Thanks Sean!
@cristopherescorcia3276
@cristopherescorcia3276 3 жыл бұрын
Man love your videos, you are the reason i am learning Swift
@DaveJacobseniOS
@DaveJacobseniOS 3 жыл бұрын
Good stuff! Thanks for the run through.
@Eugene.Berezin
@Eugene.Berezin 3 жыл бұрын
Yup! I’ve noticed that too. Removing a separator for a row is also not working if it’s not in ForEach!
@VladimirWeinsteinPhotography
@VladimirWeinsteinPhotography 3 жыл бұрын
This was great, thanks! Trying to implement a swipeAction to favorite (in this case alternating a bool in my modeldata) in the ForEach but getting an error, since the ForEach is a read-only copy of the array. What would be the best solution for something like that?
@shaxzodziyadullayev9115
@shaxzodziyadullayev9115 8 ай бұрын
How to programmatically show swipe action buttons on image tap in that row?
@TheW1ZrdProductions
@TheW1ZrdProductions 3 жыл бұрын
Hey Sean, great video! Do you think they’re going to fix the functionality with the swipeActions not being available inside a NavigatoinView? The mail app on iOS does this so it might work. Otherwise how would you suggest making these cells interactive to pull up another view?
@Pobe16
@Pobe16 3 жыл бұрын
Can I set one of the buttons to be main one when doing a full swipe?
@FlashGamer521
@FlashGamer521 Жыл бұрын
I don't see any List Tutorial code in the Description...
@vamsi3877
@vamsi3877 3 жыл бұрын
SwiftUI becoming more handy
@VitVids
@VitVids 2 жыл бұрын
Is there a way to have those actions without background (and make custom buttons)? E.g. you use List without separators and each row has view with rounded corners and paddings (look at the navigation center). Default swipe actions won’t look good here.
@jalexromero
@jalexromero 2 жыл бұрын
wow awesome video! I wish I had watched this Monday, as I spent last two days figuring out lists. I have a question, hope you see it and are able to comment... when you add a navigation link to the list, it adds a ">" symbol on the right hand side of every list element... is there a way to eliminate this? Just curious, as I don't like how it looks, is redundant, and steals real estate for your content... Anyway hope you have any suggestions here to eliminate this navigation symbol. I've tried a few things but so far not working and need to move on to next part of my project... Thanks & keep up the great videos!
@FabricioMTL
@FabricioMTL Жыл бұрын
Hey Sean how to do this when you have a NavigationLink
@ghantasalavarichannel857
@ghantasalavarichannel857 2 жыл бұрын
Hi Sean, There is a problem to show both icon and text on Swipe Actions in SwiftUI for macOS 12. It is not working for me. Can you please provide me some idea.
@gregohb
@gregohb 3 жыл бұрын
Is there a download link for the code?
@kdtechniquesofficial6153
@kdtechniquesofficial6153 3 жыл бұрын
NavigationView{ List{ ForEach(VideoListArray){ video in NavigationLink( destination: VideoDetailView(video: video) ,label: { VideoCell(video: video) }) .swipeActions(edge: .trailing, allowsFullSwipe: false) { Button(role: .destructive){ print("Delete") }label:{ Image(systemName: "trash.circle.fill") } } } } Hello Sean bro. I think your swipe actions didn't work with the navigation links you created right. Because you need to set swipe actions not to the video cell you created but for the navigation link. For each loop is also needed. Thanks for making this video. I learned these function from you video. Then i realised how to solve swipe action problem on the navigation link.
@seanallen
@seanallen 3 жыл бұрын
Nice! Thanks for sharing. I'll have to test that out. I appreciate it!
@user-hm5dx7yi3s
@user-hm5dx7yi3s 2 жыл бұрын
Can use swipeAction in Xcode12?
@dominikgrodl7822
@dominikgrodl7822 3 жыл бұрын
Hi Sean. Great video as always! Just wanted to follow on the fact that the full swipe wasn't available on your simulator- it works in my code, the system grabs the button which is closest to the respective edge (which is even the default behaviour throughout the system, f.e. in the Mail app). I don't know what makes it not work in your code or what makes it work in mine though, just wanted to clarify that.
@seanallen
@seanallen 3 жыл бұрын
Thanks for pointing this out. Good to know!
@tonyd6853
@tonyd6853 3 жыл бұрын
Haven't these been around for a long time?
@seanallen
@seanallen 3 жыл бұрын
On the iOS platform, yes. However, SwiftUI received a new modifier in iOS 15 that handles this easily.
@nileshjdarji
@nileshjdarji 3 жыл бұрын
A quick side question. Do SwiftUI have UserDefaults equivalent?
@nileshjdarji
@nileshjdarji 3 жыл бұрын
@Omeir Ahmed Khan Thank you Omeir.
@gofudgeyourselves9024
@gofudgeyourselves9024 3 жыл бұрын
baby face is back
@KenjiEmura
@KenjiEmura 2 жыл бұрын
How can I also show the swipeActions options when the cell is tapped?
@shaxzodziyadullayev9115
@shaxzodziyadullayev9115 8 ай бұрын
hello, did you find solution to your question?
@KenjiEmura
@KenjiEmura 8 ай бұрын
@@shaxzodziyadullayev9115Hi, unfortunately I don’t remember what I ended up doing
@VasaMusic438
@VasaMusic438 3 жыл бұрын
with all these curly braces is will be very easy to get lost
SwiftUI Gradient Buttons | Linear, Radial & Angular Gradients
9:55
SwiftUI List with Custom Cell & Passing Data
36:27
Sean Allen
Рет қаралды 115 М.
He sees meat everywhere 😄🥩
00:11
AngLova
Рет қаралды 11 МЛН
WHO LAUGHS LAST LAUGHS BEST 😎 #comedy
00:18
HaHaWhat
Рет қаралды 17 МЛН
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 103 МЛН
Your App Will Get Rejected | New Privacy Rules - 2024
11:26
Sean Allen
Рет қаралды 34 М.
How to Get User Location on a Map - Swift
26:11
Sean Allen
Рет қаралды 62 М.
Easy Custom Animated Tab Bar in SwiftUI Tutorial for iOS 15
13:20
SwiftUI List Explained | All Modifiers & Styles
11:49
Flo writes Code
Рет қаралды 2,6 М.
SwiftUI Navigation - NavigationView & NavigationLink Tutorial
17:34
Add custom List Swipe Actions in SwiftUI | Bootcamp #58
9:14
Swiftful Thinking
Рет қаралды 11 М.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,7 МЛН
Опять съемные крышки в смартфонах? #cmf
0:50