В табличном представлении пользователь может нажать верхнюю правую кнопку (справа от панели навигации), и появится всплывающее окно настраиваемого оповещения и попросить пользователя ввести текстовое поле редактирования с двумя кнопками «Отмена» и «Сохранить».Как вы можете видеть в коде ниже.Когда я нажимаю «Сохранить», он добавляет строку и отображает «метку», чтобы подтвердить, что она работает, и теперь я хочу иметь возможность отображать все, что пользователь ввел в поле.Я прочитал весь сайт разработчиков Apple для просмотра таблиц и поискал вокруг, и все они делают не так, как я хочу.
- (void) CustomAlertView:(CustomAlertView *)alert wasDismissedWithValue:(NSString *)value
{
[authorList addObject:@"label"];
[tblSimpleTable reloadData];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Delete the row from the data source.
[authorList removeObjectAtIndex:indexPath.row];
[tblSimpleTable reloadData];
}
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.
[authorList insertObject:@"label" atIndex:[authorList count]];
[tblSimpleTable reloadData];
}
}
ОБНОВЛЕНИЕ ***
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Save"])
{
NSString *any = [NSString stringWithFormat:@"'%@'"];
[authorList addObject:any];
[tblSimpleTable reloadData];
}
}
вставить код строки
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.
NSString *any = [NSString stringWithFormat:@"'%@'"];
[authorList insertObject:any atIndex:[authorList count]];
//[authorList addObject:any];
[tblSimpleTable reloadData];
}
}