cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori SDK for iOS - FUISimplePropertyFormCell not editable/does not present keyboard when tapped

0 Kudos

I'm trying to build a simple form with a number of text field cells, some editable and some not, with a toggle switch form cell at the bottom. The cells are all displaying correctly and the toggle cell is updating correctly however, the simple form cells are not editable when tapped despite their isEditable property being set to true.

I am using a subclass of FUIFormTableViewController for the view controller and I can see the onChangeHandler is being called for the FUISwitchFormCell, just not the simple form cells.

import UIKit

import SAPFiori




class BPDetailViewController: FUIFormTableViewController {

  

  var viewModel:BPDetailViewViewModel?




	override func viewDidLoad() {

		super.viewDidLoad()

        tableView.estimatedRowHeight = 44

		self.tableView.register(FUITitleFormCell.self, forCellReuseIdentifier: FUITitleFormCell.reuseIdentifier)

        self.tableView.register(FUISimplePropertyFormCell.self, forCellReuseIdentifier: FUISimplePropertyFormCell.reuseIdentifier)

        self.tableView.register(FUISwitchFormCell.self, forCellReuseIdentifier: FUISwitchFormCell.reuseIdentifier)

	}




	override func didReceiveMemoryWarning() {

		super.didReceiveMemoryWarning()

		// Dispose of any resources that can be recreated.

  }

  

//  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

//    //super.tableView(tableView, didSelectRowAt: indexPath)

//    if let cell = tableView.cellForRow(at: indexPath) as? FUISimplePropertyFormCell{

//      cell.valueTextField.becomeFirstResponder()

//      print(cell.isEditable)

//    }

//    

//  }

  

  override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

    // Return false if you do not want the specified item to be editable.

    return true

  }




  override func numberOfSections(in tableView: UITableView) -> Int {

    return 1

  }

  

  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return 11

  }

  

  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    // Return the cell to be used at the IndexPath specified

    let cell = formCell(forRowAt: indexPath)




    return cell

  }

  

  func formCell(forRowAt indexPath:IndexPath) -> UITableViewCell{

    var cell:UITableViewCell?

    switch indexPath.row {

    case 0:

      //Title

      let formCell = tableView.dequeueReusableCell(withIdentifier: FUITitleFormCell.reuseIdentifier) as? FUITitleFormCell

      formCell?.value = viewModel?.title ?? ""

      formCell?.isEditable = false

      cell = formCell

    case 1:

      //Code

      let codeCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      codeCell?.isEditable = true

      codeCell?.keyName = "Code"

      codeCell?.value = viewModel?.code ?? ""

      cell = codeCell

    case 2:

      //Name

      let nameCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      nameCell?.isEditable = true

      nameCell?.keyName = "Name"

      nameCell?.value = viewModel?.name ?? ""

      nameCell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = nameCell

    case 3:

      //Type

      let typeCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      typeCell?.isEditable = false

      typeCell?.keyName = "Type"

      typeCell?.value = viewModel?.formattedType ?? ""

      cell = typeCell

    case 4:

      //Address

      let addressCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      addressCell?.isEditable = true

      addressCell?.keyName = "Address"

      addressCell?.value = viewModel?.address ?? ""

      addressCell?.onChangeHandler = { newValue in

        self.viewModel?.address = newValue

      }

      cell = addressCell

    case 5:

      //Zip

      let zipCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      zipCell?.isEditable = true

      zipCell?.keyName = "Zip Code"

      zipCell?.value = viewModel?.zipCode ?? ""

      zipCell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = zipCell

    case 6:

      //Phone1

      let phone1Cell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      phone1Cell?.isEditable = true

      phone1Cell?.keyName = "Priamry Phone #"

      phone1Cell?.value = viewModel?.phone1 ?? ""

      phone1Cell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = phone1Cell

    case 7:

      //Phone2

      let phone2Cell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      phone2Cell?.isEditable = true

      phone2Cell?.keyName = "Secondary Phone #"

      phone2Cell?.value = viewModel?.phone2 ?? ""

      phone2Cell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = phone2Cell

    case 8:

      //Contact Person

      let contactCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      contactCell?.isEditable = true

      contactCell?.keyName = "Contact Person"

      contactCell?.value = viewModel?.contactPerson ?? ""

      contactCell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = contactCell

    case 9:

      //Contact Email

      let emailCell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier) as? FUISimplePropertyFormCell

      emailCell?.isEditable = true

      emailCell?.keyName = "Contact Email"

      emailCell?.value = viewModel?.contactEmail ?? ""

      emailCell?.onChangeHandler = { newValue in

        self.viewModel?.name = newValue

      }

      cell = emailCell

    case 10:

      //Block Marketing

      let blockCell = tableView.dequeueReusableCell(withIdentifier: FUISwitchFormCell.reuseIdentifier) as? FUISwitchFormCell

      blockCell?.keyName = "Block Marketing Materials"

      blockCell?.value = viewModel?.blockSendingMarketingContent ?? false

      blockCell?.onChangeHandler = {newValue in

        self.viewModel?.blockSendingMarketingContent = newValue

        print(newValue)

      }

      cell = blockCell

    default:

      cell = UITableViewCell()

    }

    return cell ?? UITableViewCell()

  }

  

}

Accepted Solutions (1)

Accepted Solutions (1)

aschlosser
Employee
Employee

Grant,

We have observed an issue in the Simulator on this; have you tried either running the App on a device or disabling the hardware keyboard in the simulator (Shift-Cmd-K)? When using the soft keyboard on screen in the simulator, this should work.

Thanks
Andreas

0 Kudos

Disabling the hardware keyboard did the trick. Thanks!

Answers (0)