I have created EDITableViewCell
, a subclass of UITableViewCell
, so that I can put a UITextField
inside of it, rather than a UILabel
. I use EDITableView
when overriding tableView:cellForRowAtIndexPath:
. I populate a few cells with dummy data when initializing the app. The app seems to run fine. The UITableView
is displayed as expected with three rows of the table populated with dummy data. The problem I am experiencing has do with scrolling the table.
UITableView
. Because there are only three items, the table view bounces right back to where it was on touch up. UITextField
doesn't extend to), there is scrolling in response as well. Note: I have experienced this same (mis)behavior both with a programmatically-created subclassed UITableViewCell
approach as well as with a prototype Storyboard approach.
It seems to me that the UITextField
is in some way inhibiting the scrolling of my UITableView
. Why would this be happening?
If this is inevitable, how would I go about creating a UITableViewCell
subclass that does allow for in-place editing without inhibiting the scrolling?
Motivation: Like the edit event portion of Apple's Calendar app and many ToDo list apps, I want a UITableView full of cells that can be edited in-place, as opposed to segueing or using modals to edit elsewhere.
The issue here is having a UIResponder object (your UITextField) that is capturing the tap event and basically holding it so the UIScrollView (your table view) does not receive those events. A couple of suggestions for you to try:
becomeFirstResponder
when needed. For the first suggestion, your subclass would do something like this:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.nextResponder touchesBegan:touches withEvent:event];
}
But of course you would need to forward the other UIResponder methods as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.