Skip to Content
0

Picker View of FUIValuePickerFormCell wont appear

Oct 31, 2017 at 06:19 AM

53

avatar image
Former Member

Hi, I've autogenerated an application from the SAP Cloud SDK Assistant through this tutorial that i followed, and I'd like to use a FUIValuePickerFormCell in the detail view of the application, but can't seem to do so.

I've used the sample codes given by the SAP Fiori mentor app, and added a Table View Cell of class "FUIValuePickerFormCell" in main.storyboard, but nothing happens when the cell is tapped, the pickerview doesn't come up, nor is the cell editable. Does anyone knows why is this so? Below are the codes that I used

case 6:
let cell = tableView.dequeueReusableCell(withIdentifier: FUIValuePickerFormCell.reuseIdentifier, for: indexPath) as! FUIValuePickerFormCell
            valuePickerCell = cell
            cell.isEditable = true
            cell.keyName = "Appointment Status"
            cell.valueOptions = ["1", "2", "3"]
            cell.value = 0 //index of first value
            cell.onChangeHandler = { newValue in
                if let option = self.valuePickerCell?.valueOptions[newValue]{
                    print("Selectede value option \(option)")
                }
            }
            return cell

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Florian Pfeffer
Oct 31, 2017 at 09:54 AM
0

Some questions:

- Is your table view controller a subclass of FUIFormTableViewController?

- You did not set the cell height to a fix value?

Regards,
Florian

Show 8 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I've set the detail class view controller to "class DetailViewController: FUIFormTableViewController", where it was originally "class DetailViewController: UITableViewController", but the same problems still occurs, and yes I've setted the cell height to a fixed value.
I'm currently configuring my cells through a delegate

0

The cell height may NOT be set to a fixed height, because otherwise the picker cell cannot expand.

0
Former Member
Florian Pfeffer

Sorry my bad, I meant to say that my cell height does not a has fixed height, below are my current codes for it

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension
0

Tested it with a "quick and dirty" example with success.

Steps:

- Created a new TableViewController on the storyboard.

- Create a new TableViewController class with following coding and assigned it to the TableViewController in the storyboard. The registration of the FUIValuePickerFormCell happens in the coding as you did it and not in the storyboard itself.

import SAPFiori

class TableViewController: FUIFormTableViewController {

    private var appointmentStatusOptions = ["1", "2", "3"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        configureTableView()
    }
    
    private func configureTableView() {
        tableView.estimatedRowHeight = 44
        tableView.rowHeight = UITableViewAutomaticDimension
        
        tableView.register(FUIValuePickerFormCell.self, forCellReuseIdentifier: FUIValuePickerFormCell.reuseIdentifier)
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: FUIValuePickerFormCell.reuseIdentifier, for: indexPath) as! FUIValuePickerFormCell
        
        cell.isEditable = true
        cell.keyName = "Appointment Status"
        cell.valueOptions = appointmentStatusOptions
        cell.value = 0
        cell.onChangeHandler = { [weak self] selectedValueIndex in
            guard let strongSelf = self else { return }
            FUIToastMessage.show(message: "Selected Appointment Status: \(strongSelf.appointmentStatusOptions[selectedValueIndex])")
        }
        
        return cell
    }

}
0
Former Member
Florian Pfeffer

yes it works on a clean app, but for some reason it just doesn't work on the app generated by the Cloud Platform SDK for iOS Assistant

0

Then there might be some issue you oversee, but without more context here it is hard to figure out your issue.

0
Show more comments
Former Member
Florian Pfeffer

could it be coding the cell in a delegate that is causing the issue? From what I currently understand, the structure of the generated app seems to be the DetailViewController takes in a DetailViewDelegate, in which the DetailViewDelegate branches into individual delegates, and in these individual delegates is where the cells are coded

0