if you have nested for loop or the for loop need to be break in special condition
use 'break label' can satisfy your demand
●Java
myForLoop: {
for (; ; ;) {
if(someCondition == True)
break myForLoop;
}
}
●Objective-C
for (;;)
{
for (;;)
{
break; /* breaks inner loop */
}
for (;;)
{
goto myForLoop; /* breaks outer loop */
}
}
myForLoop:;
Swipe to delete UITableViewCell
●iOS (2.0 and later)
●iOS (8.0 and later)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.myData removeObjectAtIndex:indexPath.row];
[tableView reloadData];
}
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[self.myData removeObjectAtIndex:indexPath.row];
[tableView reloadData];
deleteAction.backgroundColor = [UIColor redColor];
return @[deleteAction];
}
But swipe to delete doesn't work at iOS8
It's Apple's Bug!!!
How to solve?
add the old method 'commitEditingStyle' as below
But swipe to delete doesn't work at iOS8
It's Apple's Bug!!!
How to solve?
add the old method 'commitEditingStyle' as below
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
}
Although the Objective-C has the description about the commitEditingStyle as following, iOS 8 is still not working without this method T__T
// After a row has the minus or plus button invoked (based on the UITableViewCellEditingStyle for the cell), the dataSource must commit the change
// Not called for edit actions using UITableViewRowAction - the action's handler will be invoked instead
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
訂閱:
文章 (Atom)