Form in IOS


I'm doing an app in swift and I need to make a form like this:

At the beginning I was doing it with a UITableVIew , but at the time of writing, when the keyboard was displayed, I scrolled and the field was not visible.

I have also used a library but it can not be done as in the photo, either because you can not make an image picker or because of the shape of the boxes ...

Any solution to do something similar?

asked by 30.09.2016 в 07:12

2 answers


I think you could do it as you originally thought and to solve the issue of the keyboard hiding the field you could use the pod: "IQKeyboardManagerSwift", which will move the view when selecting a field.

Link pod: link

answered by 07.10.2016 / 17:46

I think the most direct thing would be to use UITextField with the empty style border (the first option shown in the interface builder ) and transparent background. Then you put each UITextField within a UIView to which you put a white background.

To handle the movement of the keyboard you can add an observer to NSNotificationCenter that detects UIKeyboardWillShowNotification .

All UIView must be within a UIView that covers the entire page and it must be within a UIScrollView , which will allow the movement of the view up and down when it appears and disappears. keyboard, respectively.

Then, make all UITextField have delegate to the controller that you are using to show these elements; Said controller must implement the methods of UITextFieldDelegate and UITextViewDelegate (the latter in case you also want to use some UITextView ).

- (void)textFieldDidBeginEditing:(UITextField *)textField
    _activeField = textField;

- (void)textFieldDidEndEditing:(UITextField *)textField
    _activeField = nil;

And finally you do what they show in this link: link

Basically they show the calculations made to move UIScrollView upon detection of the keyboard notification, based on what UITextField is being used (variable _activeField ).

answered by 17.10.2016 в 01:59