Показаны сообщения с ярлыком UITableView. Показать все сообщения
Показаны сообщения с ярлыком UITableView. Показать все сообщения

Удаление строк в UITableView

В классе MainTableViewController добавим следующие методы:

// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}



// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        UILocalNotification *notification = [self.arrayEvents objectAtIndex:indexPath.row];
        [[UIApplication sharedApplication] cancelLocalNotification:notification];
        [self.arrayEvents removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}


Использование UITableView на iOS

Enterprise Objects Framework предшественник Core Data работал с такими базами данных как Oracle, Sybase, OpenBase и Informix.

На iOS таблицы имеют много строк и один столбец. На Mac OS может быть множество столбцов.

Главные компоненты:

Cell. UITableView состоит из ячеек. Ячейки могут содержать данные в форме изображения и/или текста, также они могут содержать элементы позволяющие выбирать, кнопки, галочки. Примеры ячеек на рисунке снизу слева:  Location Services, General, Twitter, Safari, и Photos.


Sections. Таблица также может содержать секции. На рисунке выше справа видно заголовки секций: General, Privacy, и Security. Секция Security также имеет footer (Warn when visiting fraudulent websites). У третьей группы (Clear History and Clear Cookies and Data) нет ни заголовка ни footer-a.

Accessory View. Ячейки могут иметь дополнительный вид, который обычно располагается справа. Дополнительный вид может содержать disclosure triangle или настройки как показано на рисунке выше для Safari. Еще может быть изображение или текст как для Location Services.