Note that there are some explanatory texts on larger screens.

plurals
  1. POFocus on UITextField does not work
    primarykey
    data
    text
    <p><br> In my iPhone application I have a UIScrollView with several UITextFields.<br> Using BSKeyboardControls I have added Prev/Next/Done buttons to move between the fields. However, the focus on the selected field is not working, meaning that the text field is actually still under the keyboard although selected.<br> <code>becomeFirstResponder</code> is activated but just don't set the focus.<br> Any ideas what might be wrong?<br> Thanks<br><br> In the H file</p> <pre><code>#import "BSKeyboardControls.h" ... @interface AddClientViewController : BaseViewController&lt;UIAlertViewDelegate, UIScrollViewDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate, UITextViewDelegate, BSKeyboardControlsDelegate&gt; ... @property (strong, nonatomic) IBOutlet UITextField *firstName; @property (strong, nonatomic) IBOutlet UITextField *lastName; @property (strong, nonatomic) IBOutlet UITextField *email; @property (strong, nonatomic) IBOutlet UITextField *mobile; @property (strong, nonatomic) IBOutlet UITextField *birthday; @property (strong, nonatomic) IBOutlet UITextField *anniversary; @property (strong, nonatomic) IBOutlet UITextField *street; @property (strong, nonatomic) IBOutlet UITextField *city; @property (strong, nonatomic) IBOutlet UITextField *state; @property (strong, nonatomic) IBOutlet UITextField *zip; @property (strong, nonatomic) IBOutlet UIScrollView *scrollView; @property (nonatomic, strong) BSKeyboardControls *keyboardControls; .... </code></pre> <p>In M file</p> <pre><code>- (void)viewDidLoad { ... NSArray *fields = @[ self.firstName, self.lastName, self.email, self.mobile, self.birthday, self.anniversary, self.street, self.city, self.state, self.zip]; [self setKeyboardControls:[[BSKeyboardControls alloc] initWithFields:fields]]; [self.keyboardControls setDelegate:self]; } - (void)keyboardControlsDonePressed:(BSKeyboardControls *)keyboardControls { [keyboardControls.activeField resignFirstResponder]; } - (void)keyboardControls:(BSKeyboardControls *)keyboardControls directionPressed:(BSKeyboardControlsDirection)direction { UIView *view = keyboardControls.activeField.superview.superview; [self.scrollView scrollRectToVisible:view.frame animated:YES]; } - (void)keyboardControls:(BSKeyboardControls *)keyboardControls selectedField:(UIView *)field inDirection:(BSKeyboardControlsDirection)direction { UIView *view = keyboardControls.activeField.superview.superview; [self.scrollView scrollRectToVisible:view.frame animated:YES]; } - (void)textFieldDidBeginEditing:(UITextField *)textField { [self.keyboardControls setActiveField:textField]; } - (void)textViewDidBeginEditing:(UITextView *)textView { [self.keyboardControls setActiveField:textView]; } </code></pre> <p>The setActiveField in BSKeyboardControls</p> <pre><code>- (void)setActiveField:(id)activeField { if (activeField != _activeField) { if ([self.fields containsObject:activeField]) { _activeField = activeField; if (![activeField isFirstResponder]) { [activeField becomeFirstResponder]; } [self updateSegmentedControlEnabledStates]; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload