Skip to content

Instantly share code, notes, and snippets.

@Sophrinix
Created August 31, 2013 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sophrinix/6396850 to your computer and use it in GitHub Desktop.
Save Sophrinix/6396850 to your computer and use it in GitHub Desktop.
UITableViewCellEditingStyleInsert in titanium mobile as styleInsert
// 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