Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Can';t在文本字段中导航_Ios_Navigation_Uitextfield - Fatal编程技术网

Ios Can';t在文本字段中导航

Ios Can';t在文本字段中导航,ios,navigation,uitextfield,Ios,Navigation,Uitextfield,我想浏览UITextfields,但我有一个问题,因为nextresponder总是为零,我不明白为什么。正因为如此,导航无法工作 我使用这种方法: - (BOOL)textFieldShouldReturn:(UITextField*)textField { UITableViewCell * curentCell = (UITableViewCell *)[[textField superview] superview]; NSIndexPath * indexPath = [tabl

我想浏览UITextfields,但我有一个问题,因为nextresponder总是为零,我不明白为什么。正因为如此,导航无法工作

我使用这种方法:

  - (BOOL)textFieldShouldReturn:(UITextField*)textField {

UITableViewCell * curentCell = (UITableViewCell *)[[textField superview] superview];
NSIndexPath * indexPath = [tableView indexPathForCell:curentCell];

NSInteger nextTag;
if (indexPath.row == 3)
    nextTag = textField.tag + 3;
else if (indexPath.row == 6)
    nextTag = textField.tag + 1;
else if (indexPath.row == 7)
    nextTag = textField.tag + 1;
else if (indexPath.row == 8)
    nextTag = textField.tag + 2;

UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];

if (nextResponder) {
    [nextResponder becomeFirstResponder];
} else {
    [textField resignFirstResponder];
}

[self deleteBarButton];

tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);

return NO;
}
以下是我初始化单元格的方法:

- (void) initCells
{
NSArray *topLevelObjectsProdus = [[NSBundle mainBundle] loadNibNamed:@"CellProdusAsigurareHeader" owner:self options:nil];
cellHeader = [topLevelObjectsProdus objectAtIndex:0];
UIImageView * img = (UIImageView *)[cellHeader viewWithTag:1];
img.image = [UIImage imageNamed:@"calculator-casco.png"];

NSArray *topLevelObjectsMarca = [[NSBundle mainBundle] loadNibNamed:@"CellAutovehicul" owner:self options:nil];
cellMasina = [topLevelObjectsMarca objectAtIndex:0];
UILabel * lblCell = (UILabel *)[cellMasina viewWithTag:2];
UIImageView * imgBgAuto = (UIImageView *)[cellMasina viewWithTag:5];
imgBgAuto.image =[UIImage imageNamed:@"alege-masina-portocaliu.png"];

lblCell.textColor = [YTOUtils colorFromHexString:ColorTitlu];
lblCell.text = @"Alege masina";

NSArray *topLevelObjectsProprietar = [[NSBundle mainBundle] loadNibNamed:@"CellPersoana" owner:self options:nil];
cellProprietar = [topLevelObjectsProprietar objectAtIndex:0];
UIImageView * imgBgProprietar = (UIImageView *)[cellProprietar viewWithTag:5];
imgBgProprietar.image =[UIImage imageNamed:@"alege-masina-portocaliu.png"];
UILabel * lblCellP = (UILabel *)[cellProprietar viewWithTag:2];
lblCellP.textColor = [YTOUtils colorFromHexString:ColorTitlu];
lblCellP.text = @"Alege proprietar";

NSArray *topLevelObjectsnrKm = [[NSBundle mainBundle] loadNibNamed:@"CellView_Numeric" owner:self options:nil];
cellNrKm = [topLevelObjectsnrKm objectAtIndex:0];
txtNumarKm = (UITextField *)[cellNrKm viewWithTag:2];
[(UILabel *)[cellNrKm viewWithTag:1] setText:@"Numar kilometri autovehicul"];
[(UITextField *)[cellNrKm viewWithTag:2] setKeyboardType:UIKeyboardTypeNumberPad];
[YTOUtils setCellFormularStyle:cellNrKm];

NSArray *topLevelObjectsCuloare = [[NSBundle mainBundle] loadNibNamed:@"CellView_String" owner:self options:nil];
cellCuloare = [topLevelObjectsCuloare objectAtIndex:0];
txtCuloare = (UITextField *)[cellCuloare viewWithTag:2];
[(UILabel *)[cellCuloare viewWithTag:1] setText:@"Culoare autovehicul"];
[YTOUtils setCellFormularStyle:cellCuloare];

NSArray *topLevelObjectscalc = [[NSBundle mainBundle] loadNibNamed:@"CellCalculeaza" owner:self options:nil];
cellCalculeaza = [topLevelObjectscalc objectAtIndex:0];
UIImageView * imgBgCalculeaza = (UIImageView *)[cellCalculeaza viewWithTag:1];
imgBgCalculeaza.image =[UIImage imageNamed:@"calculeaza-casco.png"];
UILabel * lblCellC = (UILabel *)[cellCalculeaza viewWithTag:2];
lblCellC.textColor = [YTOUtils colorFromHexString:ColorTitlu];
lblCellC.text = @"Cere oferta";
 }

我认为你应该通过:

我注意到了另一件事:那

所有“tabbable”UITextFields都在同一父视图上。

所以也要检查一下


希望它能对您有所帮助。

@MariaStoica:您检查过nib中带有nextTag的组件了吗?我编辑了我的问题,以显示我如何初始化单元格,如果您的问题是这样问的。我成功地使用了NSMUTABLEARRY,我用所有文本字段进行了初始化,我想在其中导航。谢谢你Bhavin Chitroda!