2017-07-21 12 views
-1

enter image description here私はユーザーインタラクションを有効にするボタンまたはラベルを作成する必要があります。 そして、ユーザーがtextfieldの外をタップすると、テキストフィールドを無効にしようとしました。しかし、完了できませんでした。返信を事前にスウィフトで編集可能なボタン/ラベルを作成する方法

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
{ 
let currentCellDescriptor = getCellDescriptorForIndexPath(indexPath) 
       let cell:ArrowCell = tableView.dequeueReusableCell(withIdentifier: "\(idString)") as! ArrowCell 
       cell.currentMinimumValueTextField.delegate = self 
       cell.currentaximumvaluextield.delegate = self 

    cell.currentMinimumValueTextField.isEnabled = false 
       cell.currentaximumvaluextield.isEnabled = false 
} 

func textFieldDidBeginEditing(_ textField: UITextField) { 
     textField.isEnabled = true 
     print("TextField did begin editing method called") 

    } 
    func textFieldDidEndEditing(_ textField: UITextField) { 
     print("TextField did end editing method called\(textField.text!)") 
    } 

    func textFieldShouldReturn(_ textField: UITextField) -> Bool { 
     textField.resignFirstResponder(); 
     return true; 
    } 

おかげで

+0

お試しいただいたコードを追加してください。 –

+0

コード – Shpuj

+0

で質問を編集しましたもう1つの問題があります。行内のテキストフィールドのクリックがオンになっています。選択されています....テキストフィールドを選択したいと思います....ユーザーがテキストを入力できるようにする必要があります....ユーザがテキストフィールドの外にタップすると、テキストフィールドは無効にする必要があります....テキストフィールドはラベルのように振る舞います – Shpuj

答えて

0

感謝。 テキストフィールドの代理人を使用して解決策を見つけました。テキストフィールドの外側をクリックすると、テキストフィールドが無効になります。このaproachによって、テキストフィールドにスライダ値を編集して表示できます。

func textFieldDidEndEditing(_ textField: UITextField) 
{ 

    if (textField.tag == 1){ 
     let min = textField.text 
     print(min) 
     appDelegate.updatedsliderprice = true 
     appDelegate.pricesliderlowerValue = Double(min!)! 
    } 
    else 
    { 
     let max = textField.text 
     print(max) 
    appDelegate.updatedsliderprice = true 
    appDelegate.pricesliderupperValue = Double(max!)! 
    } 
    rangeSliderValueChanged(RangeSliderValue: rangeSlider) 
    tableView.reloadSections(IndexSet(integer: 2), with: UITableViewRowAnimation.fade) 
} 
関連する問題