Created
August 31, 2013 08:01
-
-
Save Sophrinix/6396850 to your computer and use it in GitHub Desktop.
UITableViewCellEditingStyleInsert in titanium mobile as styleInsert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allows customization of the editingStyle for a particular cell located at 'indexPath'. If not implemented, all editable cells will have UITableViewCellEditingStyleDelete set for them when the table has editing property set to YES. | |
- (UITableViewCellEditingStyle)tableView:(UITableView *)ourTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
RETURN_IF_SEARCH_TABLE_VIEW(UITableViewCellEditingStyleNone); | |
TiUITableViewRowProxy *row = [self rowForIndexPath:indexPath]; | |
//Yes, this looks similar to canEdit, but here we need to make the distinction between moving and editing. | |
//Actually, it's easier than that. editable or editing causes this to default true. Otherwise, it's the editable flag. | |
if ([TiUtils boolValue:[row valueForKey:@"editable"] def:editable || editing]) | |
{ | |
//Check for an "insert" style to change cell editing style to Insert rather than Delete. | |
if ([TiUtils boolValue:[row valueForKey:@"styleInsert"] def:false]) | |
{ | |
return UITableViewCellEditingStyleInsert; | |
} | |
else | |
{ | |
return UITableViewCellEditingStyleDelete; | |
} | |
} | |
return UITableViewCellEditingStyleNone; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment