Am new to Ios programming with swift 2.2
What am trying to achieve is inserting two text fields in a uitableviewcell or uitableviewcells
for example the tex
Create a subclass of UITableViewCell with two text field outlets:
class TextFieldsCell: UITableViewCell {
@IBOutlet var textfield1: UITextField!
@IBOutlet var textfield2: UITextField!
}
In IB, select your table view and add a prototype cell to your table view by setting "Prototype Cells" to "1", in attributes inspector:
TextFieldsCell's IBOutlets with the corresponding text fields:In your view controller which contains the table view, implement the following:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: TextFieldsCell = tableView.dequeueReusableCellWithIdentifier("TextFieldsCell") as! TextFieldsCell
return cell
}
If you set everything up properly, you should see this on the next run: