Я переопределяю tableView: commitEditingStyle: forRowAtIndexPath, чтобы он стал методом, который сбрасывает текстовые метки в моих uitableviewcells, однако этот шов вызывает ошибки, когда пользователь затем касается uitableview ... его нужно коснуться один раз, прежде чем он что-то сделает (так чтобы получить ответ, нужны два прикосновения.)
Я надеюсь, что кто-то может помочь, кто также был в аналогичной ситуации ;. Мой код приведен ниже. Я отлаживал его до метода tableView: commitEditingStyle: forRowAtIndexPath, как будто я закомментировал tableview: titleForDeleteConfirmationButtonForRowAtIndexPath: метод, то же самое по-прежнему происходит .. Так что я думаю, что я делаю что-то неправильно, переопределяя другой метод.
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"Clear";
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
//[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
//reset uitableviewcell textlabel with default input "empty"
vehicleSearchObjectString = @"empty";
[self.tableView reloadData]; //reloads the tabels so you can see the value.
}
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
}
}
UPDATE
Здесь я установил текстовую метку uitableviewcell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"VehicleSearchCell" owner:self options:nil];
cell = vehicleSearchCell;
self.vehicleSearchCell = nil;
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
UILabel *label1;
label1 = (UILabel *)[cell viewWithTag:1];
label1.text = @"Manufacture";
UILabel *label2;
label2 = (UILabel *)[cell viewWithTag:2];
label2.text = vehicleSearchObjectString;
}
//...