, хотя я получил некоторую помощь, я не могу найти исправление так легко, просто из подсказок, поскольку я очень новичок в этом, это приложение, которому несколько лет, m пытается заставить его работать по современным стандартам, хотя это не моя основная область, в настоящее время это моя задача.iOS: сбой при вводе текстового поля при вызове функции магазина
У меня есть форма, которая сохраняет ДАННЫЕ положить в него, но он выходит из строя при первом входе, независимо от того, текстового поля я выбираю, чтобы начать с, я получаю сообщение об ошибке из этой строки:
[self saveValue:cell.textInput.text forRow:path.row atSection:path.section];
ошибка:
[UITableViewWrapperView textInput]: unrecognized selector sent to instance 0x106958c00
контекст:
-(void)textFieldDidChange:(NSNotification *)notif {
atelierFormInputCell *cell = (atelierFormInputCell*) [[[(UITextField*)notif.object superview] superview] superview] ;
NSIndexPath *path = [form indexPathForCell:cell];
[self saveValue:cell.textInput.text forRow:path.row atSection:path.section];
}
saveValue функция:
-(BOOL)saveValue:(NSString *)value forRow:(NSInteger) row atSection:(NSInteger) section {
switch (section) {
case 0:
switch (row) {
case 0:
car.marque = value;
break;
case 1:
car.modele = value;
break;
case 2:
car.mise_en_circul = value;
break;
case 3:
car.immatriculation = value;
break;
case 4:
car.num_serie = value;
break;
}
break;
case 1:
switch (row) {
case 0:
car.code_clef = value;
break;
case 1:
car.code_autoradio = value;
break;
case 2:
car.taille_pneu_avant = value;
break;
case 3:
car.taille_pneu_arriere = value;
break;
case 4:
car.pression_pneu_avant = value;
break;
case 5:
car.pression_pneu_arriere = value;
break;
}
break;
case 2:
switch (row) {
case 0:
car.type_huile = value;
break;
}
break;
case 3:
switch (row) {
case 0:
car.date_achat = value;
break;
case 1:
car.km_init = value;
break;
}
break;
case 4:
switch (row) {
case 0:
car.nom_assurance = value;
break;
case 1:
car.num_assurance = value;
break;
}
break;
case 5:
switch (row) {
case 0:
if ([car.choix_last_entretien isEqualToString:@"date"]) car.date_last_entretien = value;
else car.km_last_entretien = value;
break;
case 1:
if ([car.choix_next_entretien isEqualToString:@"date"]) car.date_next_entretien = value;
else car.km_next_entretien = value;
break;
case 2:
car.date_last_ct = value;
break;
case 3:
car.date_next_ct = value;
break;
}
break;
case 6:
switch (row) {
case 0:
car.notes = value;
break;
}
break;
}
return YES;
}
из предложений, которые я попытался изменить:
atelierFormInputCell *cell = (atelierFormInputCell*) [[[(UITextField*)notif.object superview] superview] superview] ;
в
atelierFormInputCell *cell =(atelierFormInputCell *) [(UITextField*)notif superview];
, но он выходит из строя в той же точке, что дает мне эту ошибку: [NSConcreteNotification супервизор]: непризнанный селектор, отправленный в экземпляр 0x1702580f0
для линии:
atelierFormInputCell *cell =(atelierFormInputCell *) [(UITextField*)notif superview];
, так что я не знаю, если это прогресс или хуже.
Обновление с atelierFormInputCell файлов
atelierFormInputCell.h:
@interface atelierFormInputCell : UITableViewCell {
UILabel *label;
UITextField *textInput;
NSUInteger row;
}
atelierFormInputCell.m:
@implementation atelierFormInputCell
@synthesize label, textInput, row;
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIColor *gris = [UIColor colorWithRed:108/255.0 green:116/255.0 blue:120/255.0 alpha:1.0];
UIColor *black = [UIColor blackColor];
UIColor *transparent = [UIColor clearColor];
label = [[UILabel alloc]init];
label.textAlignment = UITextAlignmentLeft;
label.font = [UIFont fontWithName:@"FontType-Normal" size:14.0];
label.backgroundColor = transparent;
label.textColor = gris;
label.numberOfLines = 1;
textInput = [[UITextField alloc] init];
textInput.borderStyle = UITextBorderStyleNone;
textInput.textAlignment = UITextAlignmentRight;
textInput.backgroundColor = transparent;
textInput.font = [UIFont fontWithName:@"FontType-Normal" size:14.0];
textInput.backgroundColor = transparent;
textInput.textColor = black;
textInput.returnKeyType = UIReturnKeyDone;
[self.contentView addSubview:label];
[self.contentView addSubview:textInput];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
Не могли бы вы показать интерфейс 'atelierFormInputCell'? – dirtydanee
@dirtydanee отредактировал ответ :) –