How to implement left AND right swipe in SwipeCellKit
up vote
0
down vote
favorite
I'm following a tutorial to create a simple to-do app where I want the user to be able to swipe left to edit the cell and swipe right to delete the cell by using SwipeCellKit. I have created a swipetableviewcontroller to run the code so that I can call it in other viewcontrollers and have used the code documentation on the github repo SwipeCellKit. This is the code I have added:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]?
guard orientation == .right else return nil
let deleteAction = SwipeAction(style: .destructive, title: "Delete") action, indexPath in
// handle action by updating model with deletion
// customize the action appearance
deleteAction.image = UIImage(named: "delete")
return [deleteAction]
Where do I implement the LEFT orientation?
(Please be kind, i'm just a newbie so I apologise if this is a stupid question)
swift xcode
New contributor
add a comment |
up vote
0
down vote
favorite
I'm following a tutorial to create a simple to-do app where I want the user to be able to swipe left to edit the cell and swipe right to delete the cell by using SwipeCellKit. I have created a swipetableviewcontroller to run the code so that I can call it in other viewcontrollers and have used the code documentation on the github repo SwipeCellKit. This is the code I have added:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]?
guard orientation == .right else return nil
let deleteAction = SwipeAction(style: .destructive, title: "Delete") action, indexPath in
// handle action by updating model with deletion
// customize the action appearance
deleteAction.image = UIImage(named: "delete")
return [deleteAction]
Where do I implement the LEFT orientation?
(Please be kind, i'm just a newbie so I apologise if this is a stupid question)
swift xcode
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm following a tutorial to create a simple to-do app where I want the user to be able to swipe left to edit the cell and swipe right to delete the cell by using SwipeCellKit. I have created a swipetableviewcontroller to run the code so that I can call it in other viewcontrollers and have used the code documentation on the github repo SwipeCellKit. This is the code I have added:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]?
guard orientation == .right else return nil
let deleteAction = SwipeAction(style: .destructive, title: "Delete") action, indexPath in
// handle action by updating model with deletion
// customize the action appearance
deleteAction.image = UIImage(named: "delete")
return [deleteAction]
Where do I implement the LEFT orientation?
(Please be kind, i'm just a newbie so I apologise if this is a stupid question)
swift xcode
New contributor
I'm following a tutorial to create a simple to-do app where I want the user to be able to swipe left to edit the cell and swipe right to delete the cell by using SwipeCellKit. I have created a swipetableviewcontroller to run the code so that I can call it in other viewcontrollers and have used the code documentation on the github repo SwipeCellKit. This is the code I have added:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]?
guard orientation == .right else return nil
let deleteAction = SwipeAction(style: .destructive, title: "Delete") action, indexPath in
// handle action by updating model with deletion
// customize the action appearance
deleteAction.image = UIImage(named: "delete")
return [deleteAction]
Where do I implement the LEFT orientation?
(Please be kind, i'm just a newbie so I apologise if this is a stupid question)
swift xcode
swift xcode
New contributor
New contributor
New contributor
asked 19 hours ago
ari
62
62
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
This line is preventing you from implementing the left orientation because the guard statement is only checking for right orientation.
guard orientation == .right else return nil
If you want to handle both cases you should change the guard statement to an if statement like this:
if orientation == .right
//Do Something with right swipe
else
//Do Something with left swipe
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This line is preventing you from implementing the left orientation because the guard statement is only checking for right orientation.
guard orientation == .right else return nil
If you want to handle both cases you should change the guard statement to an if statement like this:
if orientation == .right
//Do Something with right swipe
else
//Do Something with left swipe
add a comment |
up vote
0
down vote
This line is preventing you from implementing the left orientation because the guard statement is only checking for right orientation.
guard orientation == .right else return nil
If you want to handle both cases you should change the guard statement to an if statement like this:
if orientation == .right
//Do Something with right swipe
else
//Do Something with left swipe
add a comment |
up vote
0
down vote
up vote
0
down vote
This line is preventing you from implementing the left orientation because the guard statement is only checking for right orientation.
guard orientation == .right else return nil
If you want to handle both cases you should change the guard statement to an if statement like this:
if orientation == .right
//Do Something with right swipe
else
//Do Something with left swipe
This line is preventing you from implementing the left orientation because the guard statement is only checking for right orientation.
guard orientation == .right else return nil
If you want to handle both cases you should change the guard statement to an if statement like this:
if orientation == .right
//Do Something with right swipe
else
//Do Something with left swipe
answered 14 hours ago
Arie Pinto
521411
521411
add a comment |
add a comment |
ari is a new contributor. Be nice, and check out our Code of Conduct.
ari is a new contributor. Be nice, and check out our Code of Conduct.
ari is a new contributor. Be nice, and check out our Code of Conduct.
ari is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222123%2fhow-to-implement-left-and-right-swipe-in-swipecellkit%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password