[ad_1]
I’ve view controller during which there are a number of part of tableview. In part 0 I’ve a number of row . Every row having button named as Add Feedback after I click on on button it pushes me to different view controller having textual content subject when i wrote one thing and press accomplished button then by way of delegate I passes textfield information and set it in button title. However drawback is my button current in all row adjustments worth. I would like solely chosen row in part adjustments its button title. under is my code of first viewcontroller
class MyTabViewController: UIViewController {
var addCommentsValueStore: String = "Add Feedback"
@IBOutlet weak var tabTableView : ContentWrappingTableView!
@IBAction func addCommentsAction(_ sender: UIButton) {
guard let nextVC = MyCommentsRouter.getMyCommentsViewScreen() else { return }
nextVC.passAddCommentsDelegate = self
self.navigationController?.pushViewController(nextVC, animated: true)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if(indexPath.part == 0)
{
let indetifier = "MyTabTableViewCell"
let cell = tableView.dequeueReusableCell(withIdentifier: indetifier, for: indexPath) as! MyTabTableViewCell
cell.addCommentsButton.setTitle(addCommentsValueStore, for: UIControl.State.regular)
}
return cell
}
extension MyTabViewController: AddCommentsDelegate{
func passAddComments(instruction: String) {
addCommentsValueStore = instruction
print(addCommentsValueStore)
}
}
}
under is code of second view controller:
import UIKit
protocol AddCommentsDelegate{
func passAddComments(instruction: String)
}
class MyCommentsViewController: UIViewController {
@IBOutlet var addCommentsTextField: UITextField!
var passAddCommentsDelegate: AddCommentsDelegate?
override func viewDidLoad() {
tremendous.viewDidLoad()
}
@IBAction func backActionClick(_ sender: UIButton) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func DoneActionClick(_ sender: Any) {
let dataToBeSent = addCommentsTextField.textual content
self.passAddCommentsDelegate?.passAddComments(instruction: dataToBeSent!)
self.navigationController?.popViewController(animated: true)
}
}
[ad_2]
