Quantcast
Channel: Active questions tagged uipickerview - Stack Overflow
Viewing all articles
Browse latest Browse all 592

UIPickerview as inputview to uitextfield in swift shows Keyboard for working code

$
0
0

Did anybody noticed uitextfield- pickerview behaves differently with .ipa installation for an existing working code.

I am new to IOS development. I have working code with more than 20 view controllers. Where I used UIPickerView as inputview to UITextField which is populated on a network call. The application was tested using .ipa file as well as directly installing through Xcode for a couple of iterations. Everything was working fine.

Recently When  I created the new .IPA file, none of the picker views were working after installing. All the view controllers were showing the keyboard when I tap the text field instead of the picker view selection.  Whereas the same build is working fine when I directly install/run from Xcode to mobile.

Since its application-wide, I noticed my Archive scheme > Build configuration was somehow set to Release. Based on some stack overflow answers, I have updated the archive build configuration to Debug. After that created a new .ipa file,  All the Viewcontrollers were showing the picker views correctly except one view controller. I have readded the text field and set the textfield delegate again. still no luck

I tried almost all the possibilities.  

I am completely stuck. Not sure why all of a sudden the working code is broken.

Code snippet:

@IBOutlet weak var selectAccountTB: UITextField! ...

func textFieldDidBeginEditing(_ textField: UITextField) {
        activeTextField = textField
       self.selectedItem = ""   if (activeTextField  == selectAccountTB ) {
        let toolBar = UIToolbar.init().addToolBarHandler(selectorDone: #selector(pickerDoneTapped), selectorCancel: #selector(pickerCancelTapped))
        self.activeTextField.isUserInteractionEnabled = true
        self.activeTextField.inputAccessoryView = toolBar
        if (self.activeTextField == self.selectAccountTB ) {
            self.activeTextField.inputView = self.accountPickerView
        }
    }

}



extension QTPViewController : UIPickerViewDelegate , UIPickerViewDataSource {
         
        func numberOfComponents(in pickerView: UIPickerView) -> Int {     return 1   }

        func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
            var count = 1
            if self.activeTextField == self.selectAccountTB {
                count = self.accountList.count
            } else if self.activeTextField == self.selectPayeeBankTB {
                count = self.payeeBankValueList.count
            }
            return count
        }
            func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
            var rowValue:String!
            if self.activeTextField == self.selectAccountTB
            {
                rowValue = self.accountList[row]
            } else if self.activeTextField == self.selectPayeeBankTB {
                rowValue = self.payeeBankValueList[row]
            }
            return rowValue
        }
        func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int){
            if self.activeTextField == self.selectAccountTB {
                if (!accountList.isEmpty) {
                    self.selectedItem = self.accountList[row]
                    print("Selected Item " , self.accountList[row])
                }
            }
        }

}

textfield delegate is set in storyboard.

While debugging noticed control is not coming to textFieldDidBeginEditing() at all i=n failed scenarios.

Any direction to fix the issue is much appreciated.


Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>