Re: Custom UITableViewCell parent is NIL
Re: Custom UITableViewCell parent is NIL
- Subject: Re: Custom UITableViewCell parent is NIL
- From: Michael de Haan <email@hidden>
- Date: Mon, 07 Apr 2014 21:32:46 -0700
On Apr 7, 2014, at 9:13 PM, Quincey Morris <email@hidden> wrote:
> On Apr 7, 2014, at 20:43 , Michael de Haan <email@hidden> wrote:
>
>> I have implemented a custom UITableViewCell in a (test) project with batch deletions, following the guidelines of the sample code "MultiSelectTableView". This works as expected. However, "swipe to Delete" does not work.
>> To debug this, I created a close replica using the standard UITableViewCell, and implemented this code, triggered by the dataSourceMethod, "cellForRowAtIndexPath”.
>
>> In the case of the Custom UITableViewCell, the first iteration of "parentView = view.superview" produces "nil".
>
> a. Which direction did you swipe? In a couple of iOS 7 apps I just tried, I had to swipe from right to left (outside of edit mode), whereas left to right didn’t do anything. I recall (though perhaps incorrectly, I don’t know now) that swiping left to right started a deletion in older versions of iOS.
I swipe R -> L. In the "parallel" project with a regular TableViewCell, R->Left swipe gives the expected result ie a single cell is editable.
>
> b. Why do you expect that the swipe gesture recognizer would necessarily be attached to the table cell? It may well be attached to the tableview, or to some other view.
>
I did not necessarily expect that, but that was my starting point to "climb the hierarchy", but you next point is excellent... so, that may be the reason for "nil".
> c. Why do you expect that the table cell would have a superview during ‘tableView:cellForRowAtIndexPath:’? This data source method is used to *create* cells, and they’re not inserted in the view hierarchy, I would assume, until after that method returns.
Excellent point. However, with the "traditional" UITableViewCell, it does "climb" the hierarchy, which may well be for another reason.
It still however leaves me puzzled as to why I cannot implement Swipe to delete. (the 2 usual suspects), ie
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
are implemented.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden