logo
down
shadow

How to get all custom tableview cell textField and textView value outside tableView


How to get all custom tableview cell textField and textView value outside tableView

By : Joel
Date : October 14 2020, 02:23 PM
it should still fix some issue I tried to access custom tableView cell textfield from outside tableView like this : , This return
code :
let cell = sampleTableView.cellForRow(at: indexPath) as! sampleCellView
var model = [String]()
    cell.textView.delegate = self

    cell.textView.tag = indexPath.row
}
@objc func textViewDidChange(_ tex: UITextView) {


    model[tex.tag] = tex.text!

}


Share : facebook icon twitter icon
How to reload all tableview cells, while editing a textfield in a tableview cell - iOS Swift

How to reload all tableview cells, while editing a textfield in a tableview cell - iOS Swift


By : Stefano Zanella
Date : March 29 2020, 07:55 AM
like below fixes the issue I would avoid reloading the table view at all so that you don't disturb the first responder status of your text. You could either (1) insert and delete only what's changed or (2) redecorate cells that need updating.
1. Inserting and Deleting
code :
myTableView.insertRows(at: newIndexPaths, with: .automatic)
myTableView.deleteRows(at: oldIndexPaths, with: .automatic)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
    cell.data = dataArray[indexPath.row]
    return cell
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
    decorate(cell, at: indexPath)
    return cell
}

func decorate(_ cell: UITableViewCell, at indexPath: IndexPath) {
    cell.data = dataArray[indexPath.row]
}
for cell in myTableView.visibleCells {
    if let indexPath = myTableView.indexPath(for: cell) {
        decorate(cell: cell, at: indexPath)
    }
}
UITextField in custom tableview cell. Show pickerview when cell/textfield is tapped

UITextField in custom tableview cell. Show pickerview when cell/textfield is tapped


By : Rebecca Alison
Date : March 29 2020, 07:55 AM
this will help You set data source for picker in didSelect , you need to add it to textfield delegate this line myValues = diets
code :
// UITextField Delegates
    func textFieldDidBeginEditing(_ textField: UITextField) {
         myValues = diets  // be addedd
         generalPicker()
    }
Manage tableview cell after reloading cell from tableview, Data in textfield is not getting clear

Manage tableview cell after reloading cell from tableview, Data in textfield is not getting clear


By : dave52tv
Date : March 29 2020, 07:55 AM
With these it helps TableView Cell reuse itself. Everytime it reused, prepareForReuse method is called. Override this method of your cell. Set values to nil.
Refer this link:- https://developer.apple.com/documentation/uikit/uitableviewcell/1623223-prepareforreuse
code :
override func prepareForReuse() {
    // Clean up all values

}
How can I disable all textfield of my tableview cell with one switch which not member of tableview?

How can I disable all textfield of my tableview cell with one switch which not member of tableview?


By : user2349153
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can use switch Object in cell for Row it. It is Simple logic write in below and follow instruction.
code :
@IBAction weak var switchTextField: UISwitch!
@IBAction func switchServiceTax_Action(_ sender: UISwitch) {
    tblView.reloadData()
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TBLcell
    cell.txtFirstName.resignFirstResponder()
    cell.txtFirstName.isUserInteractionEnabled = switchTextField.isOn
    return cell
}

Create custom tableView cell textField or textView tag

Create custom tableView cell textField or textView tag


By : akhil sunny vanam
Date : March 29 2020, 07:55 AM
wish helps you When you cast a literal integer string to integer, first zeros (0000...) will be omitted. That's why "00703" becomes 703
You can correct this by adding a 'one' at the first place: "100703" --> 100703
code :
import UIKit
class ViewController: UIViewController {
    var tableView: UITableView!
    let ReusedID = "**MyCell**"

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView = UITableView.init(frame: view.bounds, style: .grouped)
        tableView.register(MyCell.classForCoder(), forCellReuseIdentifier: ReusedID)
        tableView.dataSource = self
        tableView.delegate = self
        view.addSubview(tableView)
    }
}
extension ViewController: UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int { return 1 }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 8 }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: ReusedID, for: indexPath)
        if let cell = cell as? MyCell {
            cell.configCell(somethingHere: nil, parent: tableView, with: indexPath)
        }
        return cell
    }
}

/// Create a custom delegate for tableview
protocol MyTableViewDalegate: UITableViewDelegate {
    func tableView(_ tableView: UITableView?, didChange textView: UITextView, at indexPath: IndexPath)
}

/// [***] Implement the custom delegate
extension ViewController: MyTableViewDalegate {
    func tableView(_ tableView: UITableView?, didChange textView: UITextView, at indexPath: IndexPath) {
        print("table view cell did change with indexpath: ", indexPath)
    }
}

/// Custom Cell Class which implement text view delegate
class MyCell: UITableViewCell, UITextViewDelegate {
    var textView: UITextView!
    var cellIndexPath: IndexPath!
    var parent: UITableView?

    required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        textView = UITextView.init()
        textView.delegate = self
        textView.text = "Lorem ipsum sit dolor"
        addSubview(textView)
        textView.sizeToFit()
    } // End of UI preparation

    func configCell(somethingHere: Any?, parent: UITableView?, with indexPath: IndexPath) {
        self.parent = parent
        self.cellIndexPath = indexPath
    }

    // TextView Delegate
    func textViewDidChange(_ textView: UITextView) {
        let delegate = parent?.delegate as? MyTableViewDalegate
        delegate?.tableView(parent, didChange: textView, at: cellIndexPath) // <== HERE
        // The delegate will be called in [***] section above
    }
}
Related Posts Related Posts :
  • Inserting into Array and comparing Dates Swift iOS Code
  • IBDesignable UI is not showing in Xcode 9 with Swift
  • Ask for only Request Always Authorization, and not When-In-Use Authorization
  • "Google/Analytics.h file not found" after updating pod to GoogleAnalytics
  • Post request with HTTP header parameters
  • Managing cookies for a domain in Associated Domains
  • Array items showing error in IOS
  • Saving asynchronously downloaded files' contents to SQLITE
  • Swift 4 - animating both alpha and constraint affects other components alpha value
  • UIView animation in completion block starts with displacement
  • List all Apps and Track Internet Usage
  • Handling Back To Back HTTP Posts SWIFT 4.0
  • Azure App Service Push - registration endpoint
  • Select multiple item in a tableView
  • Apartment number / Unit number returned from google places api
  • How to align UICollectionViewCells from left to right?
  • How can I add search option on UIPickerview in ios?
  • Scenekit - physicsWorld setup to prevent kinematic nodes to intersect
  • Carthage Build Failed
  • swift 3, ios 10 - push notification firebase is not received
  • App Xcode 8 to Xcode 9 - Prevent Auto Hide Status Bar
  • How to pop back to a TableViewController?
  • Is UserDefaults thread safe in Swift? How to check it?
  • UISwitch in a table selects multiple cells when switch state on
  • iOS App with no story board (Size classes and Device type limitations)
  • AudioKit issue, mic not sensitive enough
  • send indexpath to Firebase (like button)
  • UIColor saturation brightness values different from the regular saturation luminosity values of a color
  • JSON: Extracting Data Using Alamofire and Swift 3
  • invalid_grant on OAuth2 request when obtaining access_token from SSO in App
  • ABNewPersonViewController using contact framework
  • Design iOS button scalable
  • Subclassing NSLayoutConstraint constant based on screen height
  • Migrate Realm 2.x List of Object to Realm 3.x List of String (or other primary type)
  • Using BLE RSSI value for connect-by-proximity
  • Backgroundcolor of NSTextfield
  • Firebase modifying uid in every view
  • How to rotate orientation?
  • Upload a new version of ios app to app store?
  • UIScrollView do not scroll down to its original position when keyboard disappear
  • What is the most effective way of tracking time/dates in an iOS/Swift application?
  • WatchKit get user's preferred handedness
  • Location permission dialog is shown and immediately disappears
  • Combine these regex expressions
  • How to save an array of HKQuantitySamples (heart rate) to a workout
  • RestKit mapping with parent key as attribute and key contains parenthesis
  • How to add UITextField programmatically to UIScrollView without breaking constraints?
  • How to make a view height grow depending on its child views contents
  • Some users experiencing NSInternalInconsistencyException crash
  • Mark successful siesta response as error
  • Using a modified PDFTron Tools Framework
  • How can I use universal links when I call openURL inside my own app?
  • NSArray of doubles iOS (Objective c)
  • Passing data from embedded PageViewController to parent View Controller
  • Reuse item inside a row when scrolling
  • Realm Relation how to implement
  • error: generic parameter 'T' could not be inferred in swift
  • Adding shadow to UITextView makes text expand out of UITextViewFrame
  • How to change the string in seconds to minutes in Swift3?
  • Search bar is refreshing the index of my table view cell
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org