logo
down
shadow

UItextfield text in Custom UITableViewCell prints nil when i scroll up in SE


UItextfield text in Custom UITableViewCell prints nil when i scroll up in SE

Content Index :

UItextfield text in Custom UITableViewCell prints nil when i scroll up in SE
Tag : ios , By : Lunis Neko
Date : November 14 2020, 03:01 PM

This might help you I am not sure if this is the best possible answer to this question, but having faced similar issues in the past the solution that worked for me was.
Store the values in a dictionary as an when the value is entered in the adjoining textField of the cell. You can achieve this by storing the value in the dictionary or an array in the method textFieldDidEndEditing and then setting it to the appropriate textField each time the cell reloads.

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Change UITextField text right before editing when using custom UITableViewCell


Tag : ios , By : Brianna
Date : March 29 2020, 07:55 AM
this one helps. I think your solution (decoupling the FRC during editing) may be a little drastic and could have unforeseen effects. Here are a couple of alternative suggestions. I am assuming the problem is caused by the table reloading the row you are editing once you have finished editing the first field in the cell.
Don't store the currency symbol in your model, add it to the displayed text in cellForRowAtIndexPath, if the text field is not editing. When your textfield begins editing, set its text to the value directly from the model. You don't have to do anything in end editing since the reload will add the currency symbol back on for you. If you dont want to change the model, you can do something similar anyway - in cellForRowAtIndexPath remove the currency symbol if the cell is editing. Store the index path of the currently editing row and conditionally ignore changes to this row in the FRC delegate method.

cellForRowAtIndexPath returns null when there's text in the custom UITableViewCell's UITextField


Tag : development , By : jonagh
Date : March 29 2020, 07:55 AM
wish of those help There's nothing wrong with the above code. I created a test project, inserted this QuestionCell (complete with UITextField and UILabel objects) and your tableView:cellForRowAtIndexPath, and everything is fine.
The UITableView method cellForRowAtIndexPath only returns nil if the cell has scrolled off the screen (and that's expected behavior). But with these six cells present, I iterated through the table's `cellForRowAtIndexPath and everything was fine, regardless if I've entered text or not.

Swift: retrieving text from a UITextField in a custom UITableViewCell and putting it in an array


Tag : ios , By : firebasket
Date : March 29 2020, 07:55 AM
This might help you There is a problem with your approach if the number of rows in your table exceeds the number that can fit on screen. In that case, the cells that scroll off-screen will be re-used, and the contents of the nameInput textField will be lost. If you can be sure that this will never happen, use the following code (in the method that handles button taps) to compose your array:
        var arrayOfNames : [String] = [String]()
        for var i = 0; i<self.arrayOfPeople.count; i++ {
            let indexPath = NSIndexPath(forRow:i, inSection:0)
            let cell : EditingCell? = self.tableView.cellForRowAtIndexPath(indexPath) as EditingCell?
            if let item = cell?.nameInput.text {
                arrayOfNames.append(item)
            }
        }
        println("\(arrayOfNames)")
    var arrayOfNames : [String] = [String]()
    var rowBeingEdited : Int? = nil
    cell.nameInput.text = "" // just in case cells are re-used, this clears the old value
    cell.nameInput.tag = indexPath.row
    cell.nameInput.delegate = self
func textFieldDidEndEditing(textField: UITextField) {
    let row = textField.tag
    if row >= arrayOfNames.count {
        for var addRow = arrayOfNames.count; addRow <= row; addRow++ {
            arrayOfNames.append("") // this adds blank rows in case the user skips rows
        }
    }
    arrayOfNames[row] = textField.text
    rowBeingEdited = nil
}

func textFieldDidBeginEditing(textField: UITextField) {
    rowBeingEdited = textField.tag
}
        if let row = rowBeingEdited {
            let indexPath = NSIndexPath(forRow:row, inSection:0)
            let cell : EditingTableViewCell? = self.tableView.cellForRowAtIndexPath(indexPath) as EditingTableViewCell?
            cell?.nameTextField.resignFirstResponder()
        }

UITextfield text inside UITableViewCell disappearing on scroll


Tag : ios , By : user179190
Date : March 29 2020, 07:55 AM
Hope that helps Your code in cellForRowAtIndexPath is fine (subject to clarifying which version of dequeueReusableCellWithIdentifier you want to use). Your problem lies in the for loop where you try to save the values. If you debug this for loop, you will find that cell is nil for any rows which are no longer on screen. You need to find a way to save the values for each row before (or as soon as) it is scrolled off screen. To do that, use the tableView delegate method:
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

Giving a UITextField, in a custom UITableViewCell, the proper text color when the cell is highlighted/selected


Tag : objective-c , By : TC.
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Update calendar 'start of week' from phones system calendar
  • Xcode is showing some warnings
  • How to remove the default Navigation Bar space in SwiftUI NavigiationView
  • Having trouble integrating multiple pickerviews in the same view
  • SCNNode not in SCNView hierarchy, still showing & getting touches & physics
  • How can I open my SwiftUI app and perform a function using NSUseractivity from within Siri Intent Extension?
  • NSCoding decodeObject always nil
  • Passing data in a segmented Controller?
  • Facing issue in Siri Integration with custom intents
  • ARKit3 Hardware Requirement Clarification
  • ARKit3 How to use TrueDepth camera for face tracking and face meshes of other people?
  • How to discriminate while decoding using Codable Protocol in Swift?
  • 'IPA processing failed' while distributing build in Xcode Beta
  • How to debug a crash which happened when come back from background
  • Synchronising old data with NSPersistentCloudKitContainer
  • iOS app opened from web app with url redirects to Appstore
  • How to change the color of seperator in tableView?
  • Is there a better way to watch for a key-value change?
  • How to make UIBezierPath to fill from the center
  • Why on Xcode 11, UICollectionViewCell changes size as soon as you scroll (I already set size in sizeForItem AtIndexPath:
  • How to scan non LE devices using Swift?
  • Unable to infer closure type in the current context in SwiftUI
  • What is the best way to write common code and use it entire project
  • UISegmentedControl inside UIStackView, segments text not centered - iOS 13
  • Swift & ObjC bridge - cannot find protocol declaration for "WKNavigationDelegate"
  • SwiftUI How to push to next screen when tapping on Button
  • 'NSApp' is unavailable in UIKit for Mac: How to embed Mac only framework in iOS app on macOS?
  • UserDefaults Binding with Toggle in SwiftUI
  • How to create a color with an alpha value using SwiftUI?
  • SwiftUI creates destination views before the user navigates to them
  • Streaming video from https with AVPlayer causes initial delay
  • Tap Action not working when Color is clear SwiftUI
  • SwiftUI NavigationButton: How to navigate to different destinations
  • Supported default light/dark mode colors for Color vs UIColor
  • XCUITest wait for a cell with a specific static text inside it
  • Not able to enable Development mode on iOS 13
  • How to hide the home indicator with SwiftUI?
  • How to write if condition with using label text (Int) values
  • Swift Cannot use instance member within property initializer
  • Issue while getting the frame of the keyboard
  • dynamicMemberLoookup ExpressibleByStringLiteral parameter swift
  • iOS Unity Firebase Messenger Xcode Compile Error: FIRDynamicLinks
  • Firebase Storage Image Cache not updating SWIFT
  • unhandled js exception: application main has not been registered expo TestFlight
  • App freezes on IOS when navigate to another screen - React Navigation
  • How to create haptic feedback for a Button in SwiftUI?
  • How can I achieve automatic scrolling in my text view when text comes down to the keyboard level in Swift?
  • how to get the location with the CLLocationManager every 10 secondes?
  • Calling completion handler of a function from Timer selector function Swift
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com