-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UITableView shows delete button on swipe cell by default #907
Comments
Hi @ishkawa , That's actually part of Apple black magic :) If your delegate implements - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath; and Rx delegate "does" because it fits under observable event spectrum, then UIKit has that unfortunate behavior. You can test it out by temporarily modifying this code in -(BOOL)respondsToSelector:(SEL)aSelector {
if (aSelector == @selector(tableView:commitEditingStyle:forRowAtIndexPath:)) {
return NO;
}
return [super respondsToSelector:aSelector]
|| [self._forwardToDelegate respondsToSelector:aSelector]
|| [self canRespondToSelector:aSelector];
} The solution for this is simple, but annoying. // viewDidLoad
tableView.rx
.setDelegate(self)
.addDisposableTo(disposeBag)
// to prevent swipe to delete behavior
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
return .none
} |
I understood what is happening. I didn't notice the cause of this issues is Thank you for the concise explanation 👍 BTW, my project contains approximately 20 Instead of implementing the delegate method in each view controllers, I suggest overriding |
If the policy I suggested is OK, I will work on it. |
…e table views. ReactiveX#907" This reverts commit db3b41c.
Hi @ishkawa , Apple's black magic is stong :)
I would like to take some time and think what is the simplest way to solve this, there is a lot of possible solutions out there, including some similar to one you've suggested. |
😇
I agree with you. It needs further consideration. |
I think this should be solved now. @ishkawa please let me know if this doesn't work. I'll close issue for now. |
Short description of the issue:
UITableView which displays cells using
rx.items
has unwanted editingStyle. It should have.none
by default, but it seems to be set as.delete
. Here's a screen shot of the bug that appeared in RxExample.Self contained code example that reproduces the issue:
https://github.com/ReactiveX/RxSwift/blob/e4e422c4f1da21aa78d9a4c982c572533f74645d/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift
Xcode version:
Expected outcome:
UITableView doesn't show delete button by default.
What actually happens:
UITableView shows delete button by default.
The text was updated successfully, but these errors were encountered: