iosswiftuipickerviewiqkeyboardmanager

PickerView Remove Placeholder label swift


Is there any way to remove Select string from top of the UIPickerView screen shot given below:

Screen Shot

Code:

var pickerVWUserList = UIPickerView() 

    //MARK:- Setup Picker View For TextField
func setupForPickerViewForTxtFld() {
    pickerVWUserList.delegate = self
    pickerVWUserList.dataSource = self
    txtfldAllGroup.inputView = pickerVWUserList
}

//MARK:- Extension for picker View
extension VC:UIPickerViewDataSource,UIPickerViewDelegate {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
    return listOfAllTypesGroups.count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
    return listOfAllTypesGroups[row].groupName
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    slctedGroupId = listOfAllTypesGroups[row].groupId
}

Thank you


Solution

  • Try this code in AppDelegate didFinishLaunchingWithOptions

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
         IQKeyboardManager.shared.enable = true
         IQKeyboardManager.shared.shouldShowToolbarPlaceholder = false
    
         return true
     }