Разве NSMutableArray может редактировать или перемещать indexPath, когда данные взяты из URL? - PullRequest
0 голосов
/ 17 января 2011

Я загружаю данные из URL в NSMutableArray, как этот код:

NSMutableArray *mArray;
mArray = [NSMutableArray arrayWithContentsOfURL:theNewURL];

Если я загружаю этот массив и показываю в табличном представлении

Могу ли я переместить индекс строки и редактировать таблицупосмотреть, ex.delete ... ???

Ответы [ 2 ]

0 голосов
/ 17 января 2011
-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{


}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {


    return UITableViewCellEditingStyleDelete;

}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{

    // If row is deleted, remove it from the list.
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {

        rowNumber = indexPath.row;

        UIActionSheet *registerActionSheet = [[UIActionSheet alloc] initWithTitle:@"Sure You Want To Delete?"delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Yes", nil];

        registerActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

        [registerActionSheet showInView:self.view];

        [registerActionSheet release];

        // delete your data item here
        // Animate the deletion from the table.
        //[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

    }
}
0 голосов
/ 17 января 2011

Да.

Вы можете удалить элемент из массива и перезагрузить tableView

NSMutableArray * mArray = [NSMutableArray arrayWithContentsOfURL:theNewURL];
[mArray removeObjectAtIndex:indexPath.row];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...