In my App I use UITableView with custom cells.
for each cell I implement function to create it, and call these functions in cellFo
Don't use the default UITableView and fight the reuse of cells, it's really embedded in it's behaviour.
Try to adapt your code so it works well with reusing cells, or if that's really impossible, you'd have to write your own custom table view I guess (but I don't recommend that at all)
Try using a different identifier for each of the cell types, so dont use "text-field-cell"
for each one, make one "full name", "password" etc. not sure how you are going about creating your cells, but if you are using the registerNib or registerClass, you will need to register it for each different identifier
self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "full name")
self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "password")
self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "email")
You shouldn't prevent that, but if you really want to, I think that not setting cell identifier to your UITableViewCell
should do the trick. When you'll call dequeueReusableCellWithIdentifier
, it will find no cell and will create a new one. But again, it's not recommended as UITableView
is made to be used with reuse ability.
Moreover, as @Fonix suggests, using a different cell identifier for each cell of your UITableView
might solve your issue while keeping using cell reuse system.
Edit :
As you're talking about losing text content in your UITextField, maybe the single change to make is changing your @propery weak
attribute to strong
.
Hope this helps.
Try to implement prepareForReuse
method in your custom cell and set all fields text to nil.
override func prepareForReuse() -> Void {
awamirTextFieldNib.text = nil
}
Hope this help