Tuesday, June 30, 2026
HomeiOS Developmentios - Why UIPickerView error: Tried to name -cellForRowAtIndexPath: on the desk...

ios – Why UIPickerView error: Tried to name -cellForRowAtIndexPath: on the desk view whereas it was within the strategy of updating its seen cells?

[ad_1]

I get the error after I open UIPickerView.
My UIPickerView has 16 gadgets.

    func open_activity_picker()
{
    activity_UIPickerView = UIPickerView()

        activity_UIPickerView.delegate = self
        activity_UIPickerView.dataSource = self
        activity_UIPickerView.backgroundColor = UIColor.white
        activity_UIPickerView.setValue(UIColor.black, forKey: "textColor")
        activity_UIPickerView.autoresizingMask = .flexibleWidth
        activity_UIPickerView.contentMode = .middle
        activity_UIPickerView.body = CGRect.init(    x: 0.0, 
                                                    y: 10,       //UIScreen.most important.bounds.dimension.top - 300, 
                                                    width: UIScreen.most important.bounds.dimension.width, 
                                                    top: 300)
        self.view.addSubview(activity_UIPickerView)
}

func numberOfComponents(in pickerView: UIPickerView) -> Int 
{
        return 1  // complete picker columns 
}


func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent element: Int) -> Int 
{
    return 16
}


func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent element: Int) -> String? 
{
            var activity_title = ""
            var nmbr_activity_title = ""
        change( row )
        {
            case 0:          activity_title = "aerobics               ";      nmbr_activity_title = " 1. aerobics               "
            case 1:          activity_title = "bike (mountain)          ";      nmbr_activity_title = " 2. bike (mountain)        "
            case 2:          activity_title = "bike (road)            ";      nmbr_activity_title = " 3. bike (road)          "
            case 3:          activity_title = "calisthenics           ";      nmbr_activity_title = " 4. calisthenics           "
            case 4:          activity_title = "golf 9 holes           ";      nmbr_activity_title = " 5. golf 9 holes           "
            case 5:          activity_title = "golf 18 holes          ";      nmbr_activity_title = " 6. golf 18 holes          "
            case 6:          activity_title = "hike average          ";      nmbr_activity_title = " 7. hike average        "
            case 7:          activity_title = "hike strenuous         ";      nmbr_activity_title = " 8. hike strenuous       "
            case 8:          activity_title = "jog                    ";      nmbr_activity_title = " 9. jog                    "
            case 9:          activity_title = "karate kata";      nmbr_activity_title = "10. karate kata"
            case 10:         activity_title = "run";      nmbr_activity_title = "11. run"
            case 11:         activity_title = "stationary workouts";      nmbr_activity_title = "12. stationary workouts"
            case 12:         activity_title = "swim";      nmbr_activity_title = "13. swim"
            case 13:         activity_title = "treadmill";      nmbr_activity_title = "14. treadmill"
            case 14:         activity_title = "stroll";      nmbr_activity_title = "15. stroll"
            case 15:         activity_title = "woopie";      nmbr_activity_title = "16. woopie"
            default:
                handle_fault("")
        }
        activity_title = TRIM( activity_title )
        activity_title = activity_title.replacingOccurrences(of: " ", with: "_", choices: .literal, vary: nil)
        activity_selection_types[ row ] = activity_title 


        // Choose boot default if no exercise chosen?
        if activity_selection_type == ""   &&   row == 0
        {
            activity_selection_type = activity_title
        }
        // row is earlier person choice of activity_selection_type?
        if activity_title == activity_selection_type
        {
            activity_UIPickerView.selectRow( row, inComponent: element, animated: true)
        }

        return( TRIM( nmbr_activity_title    ))
    }

OUTPUT —————————————————– (sorry, StackO removes linefeeds)

open_activity_picker()...  

numberOfComponents: 1
numberOfComponents: 1
numberOfRowsInComponent: 16
numberOfRowsInComponent: 16
numberOfRowsInComponent: 16
numberOfRowsInComponent: 16
numberOfRowsInComponent: 16
numberOfRowsInComponent: 16
numberOfComponents: 1
numberOfRowsInComponent: 16
——– row 0 aerobics activity_selection_type: bike_(mountain)
——– row 1 bike_(mountain) activity_selection_type: bike_(mountain)
2022-06-27 09:53:36.183633-0700 KP_to_iOS_5[38198:1313788] [Assert] Tried to name -cellForRowAtIndexPath: on the desk view whereas it was within the strategy of updating its seen cells, which isn’t allowed. Make a symbolic breakpoint at UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate to catch this within the debugger and see what prompted this to happen. Maybe you are attempting to ask the desk view for a cell from inside a desk view callback a few particular row? Desk view: <UIPickerTableView: 0x14802b400; body = (9 -170.667; 675 375); opaque = NO; gestureRecognizers = <NSArray: 0x2810fdb00>; layer = <CALayer: 0x281ef5080>; contentOffset: {0, -171.66666666666666}; contentSize: {675, 512}; adjustedContentInset: {171.66666666666666, 0, 171.33333333333334, 0}; dataSource: <UIPickerColumnView: 0x1475132f0; body = (0 0; 693 300); autoresize = W+TM+H; gestureRecognizers = <NSArray: 0x2810da970>; layer = <CALayer: 0x281ef7ea0>>>

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments