Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erdinc27

macrumors regular
Original poster
Jul 20, 2011
168
1
i want to know in which way do you create a registration form with 7 or 8 inputs and beside an image for example ?

Do you choose to use an UIScrollView and place the UITextField inside of it ?

Do you choose to use an UITableView and place the UITextfield inside each cell ?

Which one is better way ?
 
I would definitely use a static TableView with textFields rather than a scrollview with text fields. If you turn off the row separators the user won't tell the difference. The tableview controller will automatically adjust the table view for the keyboard.
 
I think so too. But i faced with a problem in that method. For example we have 10 UITextfield in form. The user starts to fill the text fields and scroll the tableview up. So the entered areas will be cleaned because of deque reusable cell. What would be done in such situation ?
 
You must use a STATIC Table View. The cells won't be dequeued in a static table view. You should have IBOutlets for all the UITextFields.

Initialize the values in all the text fields in viewDidLoad. You need ivars for the values of each text field. Set up an IBAction method from the text fields to the view controller for the valueChanged event. Call this
- (IBAction)textFieldTextDidChange:(UITextField *)textField In the action method save the text field value to the appropriate ivar.

You need to look up examples for STATIC table views.
 
Well a table view cell is not an alert controller. However, you can have a closure called when the textField changes with this custom cell:

Code:
class MyCell: UITableViewCell {
@IBOutlet weak var myButton: UIButton!
// This closure is called when the button is tapped
var buttonTapClosure:((cell:MyCell) -> ())?
@IBAction func buttonTapped(sender: UIButton) {
   if let closure = buttonTapClosure {
     closure(cell: self)
   }
}

The closure is set in cellForRowAtIndexPath.
The button is added to the cell in IB and connected to the IBOutlet and the touch up inside event is connected to the IBAction.
 
Well a table view cell is not an alert controller. However, you can have a closure called when the textField changes with this custom cell:

Code:
class MyCell: UITableViewCell {
@IBOutlet weak var myButton: UIButton!
// This closure is called when the button is tapped
var buttonTapClosure:((cell:MyCell) -> ())?
@IBAction func buttonTapped(sender: UIButton) {
   if let closure = buttonTapClosure {
     closure(cell: self)
   }
}

The closure is set in cellForRowAtIndexPath.
The button is added to the cell in IB and connected to the IBOutlet and the touch up inside event is connected to the IBAction.
Ha, right -- you suggested a tableview not me. Too much work if you ask me.
 
You can make a universal static table view, kinda like a shell. Then just add in the changes that you need for a given form. That's what I do. The template / shell code has all the basic functionality that I need, then just add the specifics needed for a given usage.
 
Thank you all guys. I think i will make it with tableView i made some examples and it seem tableview is better way.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.