私の iOS アプリには約 12 個のフィールドを持つフォームがあり、キーボードの上に「前へ」/「次へ」ボタンを追加して、ユーザーがフィールド間を移動できるようにしたいと考えていました。私はこのようなものを持っています:
for (UITextField *t in _textfields) {
    t.delegate = self;
    UIToolbar *toolbar = [[UIToolbar alloc] init];
    [toolbar setBarStyle:UIBarStyleBlackTranslucent];
    UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:@[@"Previous", @"Next"]];
    [segControl addTarget:self action:@selector(switchTextField:) forControlEvents:UIControlEventValueChanged];
    segControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segControl.tag = [_textfields indexOfObject:t];
    if (segControl.tag == 0) [segControl setEnabled:NO forSegmentAtIndex:0];
    else if (segControl.tag == [_textfields count] - 1) [segControl setEnabled:NO forSegmentAtIndex:1];
    [segControl sizeToFit];
    UIBarButtonItem *segItem = [[UIBarButtonItem alloc] initWithCustomView:segControl];
    UIBarButtonItem *flexButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem *doneButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self.view action:@selector(endEditing:)];
    [toolbar setItems:@[segItem, flexButton, doneButton]];
    [toolbar sizeToFit];
    [t setInputAccessoryView:toolbar];
}
私が抱えている問題は、セグメントの 1 つが頻繁に機能しなくなることです。メソッドswitchTextFieldが呼び出されないだけで、ボタンは無効ではなく正常に見えますが、タッチは登録されません。「前の」ボタンの場合もあれば、「次の」ボタンの場合もあり、両方が同時に機能することはなく、両方が正常に機能する場合もあります。ボタンの 1 つが動かなくなったら、それを (一時的に) 修正する唯一の方法は、ツールバーを使用せずに別のテキストフィールドをタップするか、キーボードを閉じて編集を再開することです。何が問題なのですか?