ios – UIPickerView present empty label swift


UIPickerView not working for IOS 15.5 my code was working IOS 7.0
Since i up to date to macOS Monterrey 12.5 and code 13 UIPickerView not working as anticipated anymore.
It was a easy UIPickerView for choosing a quantity.
No error or warning is acquired.
Solely present an empty grey label.

I would like so as to add one thing within the code ?

class gemePrice: UIViewController,UIGestureRecognizerDelegate,   UIImagePickerControllerDelegate , UINavigationControllerDelegate ,UITextViewDelegate ,UITableViewDelegate, UITableViewDataSource , UIPickerViewDelegate , UITextFieldDelegate{

    var pckMarkup: UIPickerView!;
var t:CGAffineTransform!;
        var s:CGAffineTransform!;
        var u:CGAffineTransform!;
        
        pckMarkup = UIPickerView(body: CGRect(x: 290, y: start_y+10, width: 60, peak: 90));
        pckMarkup.delegate = self;
        t = CGAffineTransform (translationX: 0, y: 0);
        s = CGAffineTransform (scaleX: 1.5,y: 0.7);
        u = CGAffineTransform (translationX: 0 ,y: 0);
        pckMarkup.remodel = t.concatenating (s.concatenating(u));
        pckMarkup.tag=10;
        //pckMarkup.backgroundColor = UIColor.lightGray;
        pckMarkup.backgroundColor =  UIColor(pink: 225/255, inexperienced: 235/255, blue: 239/255, alpha: 1)
        pckMarkup.layer.borderColor =  (UIColor(pink: 31/255, inexperienced: 128/255, blue: 170/255, alpha: 1).cgColor);
        
        
        pckMarkup.layer.borderWidth = 5.0
        pckMarkup.layer.masksToBounds = true
        pckMarkup.layer.cornerRadius = 8
        
       
        view.addSubview(pckMarkup);
      
        
        
        pckMarkup.selectRow(Int(markup+100.00), inComponent: 0, animated: false)
        
        
        
        let tgr = UITapGestureRecognizer(
            goal:self,
            motion:#selector(pickerTapped(_:))
        )
        
        tgr.numberOfTapsRequired = 2
        // self.view.addGestureRecognizer(tgr)     // This dispatches to faucet().
        self.pckMarkup.addGestureRecognizer(tgr)
        
        tgr.cancelsTouchesInView = false
        
        
        
        
        
        
        
        reset_markup = UIButton(body: CGRect(x: 285, y: 155, width: 45, peak: 20))
        reset_markup.setTitle("0%", for: UIControlState());
        reset_markup.contentHorizontalAlignment = UIControlContentHorizontalAlignment.middle;
        reset_markup.addTarget(self, motion: #selector(go_reset_markup), for: .touchUpInside)
        reset_markup.backgroundColor = UIColor(pink: 255/255, inexperienced: 0/255, blue: 0/255, alpha: 1)
        reset_markup.setTitleColor(UIColor.white, for: UIControlState())
        reset_markup.titleLabel!.font = UIFont(title: "Instances New Roman", dimension: 14)

func numberOfComponentsInPickerView(_ pickerView: UIPickerView) -> Int {
        return 1;
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent element: Int) -> Int {
        return 201;
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent element: Int) {
        print("row chosen (row)");
        
        
        if(pickerView.tag==10){
            self.markup=Double(row-100);
            display_price();
        }
        
        
    }
    
    
    
    func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent element: Int, reusing view: UIView?) -> UIView {
        var pickerLabel: UILabel? = (view as? UILabel)
        if pickerLabel == nil {
            pickerLabel = UILabel()
            pickerLabel?.font = UIFont(title: "Arial", dimension: 18)
            pickerLabel?.textAlignment = .middle
            
        }
        
        var return_string="";
        
        if(row<=100) {
            
            return_string = "(row - 100)%"
            
        }
        if(row>100) {
            
            return_string =  "+(row - 100)%"
            
        }
        
        pickerLabel?.textual content = return_string;
        pickerLabel?.textColor = UIColor.black
        
        return pickerLabel!
    }


 @objc func pickerTapped(_ recognizer: UITapGestureRecognizer) {
        print("markaping");
        pckMarkup.selectRow(100, inComponent: 0, animated: true)
        self.markup=0;
        display_price();
    }

Similar Posts

Leave a Reply

Your email address will not be published.