Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 为什么';IQKeyboardManager滚动我的UITableView,使我的自定义单元格';s文本字段可见_Swift_Uitableview_Scroll_Custom Cell_Iqkeyboardmanager - Fatal编程技术网

Swift 为什么';IQKeyboardManager滚动我的UITableView,使我的自定义单元格';s文本字段可见

Swift 为什么';IQKeyboardManager滚动我的UITableView,使我的自定义单元格';s文本字段可见,swift,uitableview,scroll,custom-cell,iqkeyboardmanager,Swift,Uitableview,Scroll,Custom Cell,Iqkeyboardmanager,这是我当前得到的结果(不需要的): 这是我使用变通方法得到的结果(几乎是我想要的结果): 我的问题总结如下:(1)我安装了“IQKeyboardManagerSwift”cocoapod,(2)我的UITableViewController中有一个自定义单元格,它是一个FolingCell(另一个cocoapod)并包含一个文本字段,(3)当我点击文本字段内部时,我希望视图自动向上滚动,使文本字段可见(在键盘上方),这应该由IQKeyboardManager自动处理(是的,我在AppDelega

这是我当前得到的结果(不需要的):

这是我使用变通方法得到的结果(几乎是我想要的结果):

我的问题总结如下:(1)我安装了“IQKeyboardManagerSwift”cocoapod,(2)我的UITableViewController中有一个自定义单元格,它是一个FolingCell(另一个cocoapod)并包含一个文本字段,(3)当我点击文本字段内部时,我希望视图自动向上滚动,使文本字段可见(在键盘上方),这应该由IQKeyboardManager自动处理(是的,我在AppDelegate中添加了“启用”代码)

如上面的“不需要的”结果视频所示,视图似乎试图滚动,但最终只是上下抖动,然后在键盘向上滑动并不希望地覆盖文本字段时返回原始位置

此外,我发现的一个小“解决方案”“我不想满足于在textfield的iAction editingDidEnd outlet/action函数中添加以下行:“sender.becomeFirstResponder()”。在我升级到iPhone上的XCode 12和iOS 14之前,我运行并测试我的应用程序,我不必麻烦使用“.becomeFirstResponder()”或“.resignResponder()”,因为这是IQKeyboardManager自动执行的操作。现在,添加上述代码行允许UITableViewController将视图移动到键盘上方但是,如果仔细观察,它位于键盘正上方的文本字段,这显然不是IQKeyboardManager完成的,因为IQKeyboardManager在文本字段和键盘之间有一个默认偏移量CGFloat(10)

我认为代码的相关部分是我的自定义单元格(称为“SavedImageFoldingImageCell”),因为这是我创建相关文本字段和UITableViewController(称为“SavedImageTableViewController”)的地方

请,您能提供的任何帮助、建议、建议都会对我大有帮助,我将不胜感激。谢谢

是的,我的代码看起来很可怕,因为我没有在编码或一般编码的最佳实践方面进行适当的培训/教育。建议也将不胜感激!如果你看到我可以缩短和组织我的代码的方法,就一定要泄露你的秘密

自定义单元格的代码

import UIKit
import FoldingCell
import LGButton
import TextFieldEffects
import SCLAlertView

class SavedImageFoldingImageCell: FoldingCell, UITextFieldDelegate {

// CLOSED
@IBOutlet weak var enterAGreetingLabelClosed: UILabel!
@IBOutlet weak var savedImageView1Closed: UIImageView!
@IBOutlet weak var savedImageView2Closed: UIImageView!
@IBOutlet weak var openCellButton: LGButton!


// OPEN
@IBOutlet weak var confirmLabelOpen: UILabel!
@IBOutlet weak var englishLabelOpen: UILabel!
@IBOutlet weak var spanishLabelOpen: UILabel!
@IBOutlet weak var savedImageView1Open: UIImageView!
@IBOutlet weak var savedImageView2Open: UIImageView!
@IBOutlet weak var enterAGreetingLabelOpen: UILabel!
@IBOutlet weak var enterAGreetinTextFieldOpen: HoshiTextField!
@IBOutlet weak var barViewOpen: UIView!


// 'Continue' Button
@IBOutlet weak var continueButton: LGButton!

// Hamburger Button
@IBOutlet weak var hamburgerButton: UIButton!










// MARK: - Setting-up Labels


// CLOSED Labels
var enterAGreetingClosed: String = "" {
    didSet {
        enterAGreetingLabelClosed.text = String(enterAGreetingClosed)
    }
}


// OPEN Labels
var englishOpen: String = "" {
    didSet {
        englishLabelOpen.text = String(englishOpen)
    }
}

var spanishOpen: String = "" {
    didSet {
        spanishLabelOpen.text = String(spanishOpen)
    }
}

var enterAGreetingOpen: String = "" {
    didSet {
        enterAGreetingLabelOpen.text = String(enterAGreetingOpen)
    }
}

var confirmOpen: String = "" {
    didSet {
        confirmLabelOpen.text = String(confirmOpen)
    }
}










override func awakeFromNib() {
    barViewOpen.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] // Top right corner, Top left corner respectively
    barViewOpen.clipsToBounds = true
    
    foregroundView.layer.cornerRadius = 10
    foregroundView.layer.masksToBounds = true
    
    super.awakeFromNib()
    // Initialization code
    enterAGreetinTextFieldOpen.delegate = self
}

override func animationDuration(_ itemIndex: NSInteger, type: FoldingCell.AnimationType) -> TimeInterval {
    let durations = [0.26, 0.2, 0.2]
    return durations[itemIndex]
}










@IBAction func enterAGreetingTextFieldEditingDidBegin(_ sender: HoshiTextField) {
    print("@enterAGreetingTextFieldEditingDidBegin -> cell.swift: does nothing as of now.")
}


@IBAction func enterAGreetingTextFieldEditingDidEnd(_ sender: HoshiTextField) {
    
    if sender.text!.isEmpty != true {
        // Activates and shows the 'Continue' button
        continueButton.isEnabled = true
        continueButton.alpha = 1
        
    print("enterAGreetingTextFieldEditingDidEnd@Cell -> cell.swift: activated 'Continue' button because textField contained text after editing ended.")
    } else if sender.text!.isEmpty == true {
        // Deactivates and hides the 'Continue' button
        continueButton.isEnabled = false
        continueButton.alpha = 0.5
        
        print("enterAGreetingTextFieldEditingDidEnd@Cell: deactivated 'Continue' button because textField was empty after editing ended.")
    }
}




// JUST FYI, THIS DOES NOT GET CALLED
private func textFieldShouldReturn(_ textField: HoshiTextField) -> Bool {
    let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
    let savedImageTableVC = storyboard.instantiateViewController(withIdentifier: "SavedImageTableViewController") as! SavedImageTableViewController
    savedImageTableVC.loadViewIfNeeded()

                
        if textField.text?.isEmpty == false {
            savedImageTableVC.liveGreeting = textField.text!
            savedImageTableVC.savedImageTableView.reloadData()
            print(".CELL @textFieldShouldReturn() -> savedImageTableVC.savedImagesArray: \(savedImageTableVC.savedImagesArray).")
                            
            let indexPathRow = textField.tag
            StructOperation.globalVariable.tappedCellIndexRow = indexPathRow
            print(".CELL @textFieldShouldReturn() -> StructOperation.globalVariable.tappedCellIndexRow: \(StructOperation.globalVariable.tappedCellIndexRow).")

            savedImageTableVC.goToSend()
                        
            print("User entered a greeting in enterAGreetingTextField: \(savedImageTableVC.liveGreeting).")
        } else if textField.text?.isEmpty == true {
            savedImageTableVC.liveGreeting = ""
            SCLAlertView().showError("Error", subTitle: "To send an image, a greeting must also be specified.", closeButtonTitle: "Done", timeout: nil, colorStyle: SCLAlertViewStyle.error.defaultColorInt, colorTextButton: 0xFFFFFF, circleIconImage: nil, animationStyle: .topToBottom)
                            
            print("User did not enter a greeting in enterAGreetingTextField.")
        }
    return true
}

}










// MARK: - Actions ⚡️


extension SavedImageFoldingImageCell {

@IBAction func openCellButtonTapped() {
//        print("The open-cell button was tapped (just a downward arrow).")
}

@IBAction func enterAGreetingTextfieldOpenEditingDidEnd() {
//        print("'enterAGreetingTextField' finished editing.")
}

@IBAction func continueButtonTapped(_: AnyObject) {
//        print("The 'Continue' button was tapped.")
}

@IBAction func hamburgerButtonTapped(_: AnyObject) {
//        print("The hamburger button was tapped.")
}

}
import UIKit
import TextFieldEffects
import SCLAlertView
import MessageUI
import FoldingCell
import MLKitTranslate

class SavedImageTableViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate, UITextFieldDelegate, UIContextMenuInteractionDelegate {

@IBOutlet var savedImageTableView: UITableView!


*** Omitted other irrelevant outlets, vars, & constants ***


override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    activityIndicator() // Omitted because nothing regarding the textfield is called here
    refresh() // Omitted ""
    
}

override func viewDidLoad() {
    super.viewDidLoad()
    setup() // Omitted ""; (assigned self to tableview's delegate and dataSource here)
    checkIfSavedImages() // Omitted ""
    getDeadlineInSeconds() // Omitted ""
    
    
    // For deadline countdown timer
    countdownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateCounter), userInfo: nil, repeats: true)
    
    
    // Stops loading spinner and hides view
    self.indicator.stopAnimating()
    self.indicator.hidesWhenStopped = true
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(true)
}



@IBAction func enterAGreetingTextFieldEditingDidEnd(_ sender: HoshiTextField) {
    let cell = savedImageTableView.dequeueReusableCell(withIdentifier: "SavedImageFoldingImageCell") as! SavedImageFoldingImageCell
    
    if sender.text?.isEmpty == true {
        sender.text =  ""
        cell.continueButton.isEnabled = false
        cell.continueButton.alpha = 0.5
//            sender.resignFirstResponder()
    } else if sender.text?.isEmpty == false {
        self.liveGreeting = sender.text!
        cell.continueButton.isEnabled = true
        cell.continueButton.alpha = 1
    }
}

@IBAction func enterAGreetingTextFieldEditingDidBegin(_ sender: HoshiTextField) {
    sender.becomeFirstResponder() // Fixes IQKeyboardManager (rather, allows UITableViewController to properly scroll)
    
    let indexPathRow = sender.tag
    StructOperation.globalVariable.tappedCellIndexRow = indexPathRow
    print("enterAGreetingTextFieldEditingDidEnd()@ViewController -> StructOperation.globalVariable.tappedCellIndexRow: \(StructOperation.globalVariable.tappedCellIndexRow).")
}




//MARK: - TableView Functions

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    guard case let cell as SavedImageFoldingImageCell = cell else {
        return
    }
    
    cell.enterAGreetingClosed = "Enter a Greeting"
    cell.enterAGreetingOpen = "Enter a Greeting"
    cell.englishOpen = "English"
    cell.spanishOpen = "Spanish"
    cell.confirmOpen = "Confirm"
    
    
    // Greeting TextField
    cell.enterAGreetinTextFieldOpen.delegate = self
    cell.enterAGreetinTextFieldOpen.tag = indexPath.row
    
    // Open-cell button (downward arrow)
    cell.openCellButton.tag = indexPath.row
    
    // 'Continue' button
    cell.continueButton.tag = indexPath.row
    cell.continueButton.isEnabled = false
    cell.continueButton.alpha = 0.5
    
    // Hamburger button
    cell.hamburgerButton.tag = indexPath.row
    
    
    // Closed/Open Images (English, Spanish)
    let calculatedIndex = (indexPath.row * 2) + 1
    
    cell.savedImageView1Closed.image = savedImagesArray[calculatedIndex - 1]
    cell.savedImageView2Closed.image = savedImagesArray[calculatedIndex]
        
    cell.savedImageView1Open.image = savedImagesArray[calculatedIndex - 1]
    cell.savedImageView2Open.image = savedImagesArray[calculatedIndex]

    
    
    cell.backgroundColor = .clear
    
    
    
    if cellHeights[indexPath.row] == Constants.closeCellHeight {
        cell.unfold(false, animated: false, completion: nil)
    } else {
        cell.unfold(true, animated: false, completion: nil)
    }
    
    
    
    // Allows recognition of tapping the 'Continue' button by connecting that button's outlet to a newly created function down below a little
    cell.continueButton.addTarget(self, action: #selector(SavedImageTableViewController.continueButtonTapped(_:)), for: .touchUpInside)
    // Allows recognition of tapping the 'open cell' button (just a downward arrow) by connecting that button's outlet to a newly created function down below a little
    cell.openCellButton.addTarget(self, action: #selector(openCellButtonTapped(_:)), for: .touchUpInside)
    // Allows recognition of tapping the 'hamburger' button (just three horizontal lines as a button) by connecting that button's outlet to a newly created function down below a little
    cell.hamburgerButton.addTarget(self, action: #selector(hamburgerButtonTapped(_:)), for: .touchUpInside)
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = savedImageTableView.dequeueReusableCell(withIdentifier: "SavedImageFoldingImageCell", for: indexPath) as! FoldingCell
    let durations: [TimeInterval] = [0.26, 0.2, 0.2]
    cell.durationsForExpandedState = durations
    cell.durationsForCollapsedState = durations
    
    
    return cell
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard case let cell as FoldingCell = tableView.cellForRow(at: indexPath) else {
        return
    }
    
    if cell.isAnimating() {
        return
    }
    
    var duration = 0.0
    let cellIsCollapsed = cellHeights[indexPath.row] == Constants.closeCellHeight
    if cellIsCollapsed {
        cellHeights[indexPath.row] = Constants.openCellHeight
        cell.unfold(true, animated: true, completion: nil)
        duration = 0.5
    } else {
        cellHeights[indexPath.row] = Constants.closeCellHeight
        cell.unfold(false, animated: true, completion: nil)
        duration = 0.8
    }

    UIView.animate(withDuration: duration, delay: 0, options: .curveEaseOut, animations: {
        tableView.beginUpdates()
        tableView.endUpdates()
        
        
        // fix https://github.com/Ramotion/folding-cell/issues/169
        if cell.frame.maxY > tableView.frame.maxY {
            tableView.scrollToRow(at: indexPath, at: UITableView.ScrollPosition.bottom, animated: true)
        }
    }, completion: nil)
    
    // Provide haptic feedback of success
    let generator = UINotificationFeedbackGenerator()
    generator.notificationOccurred(.success)
}

***Rest is Omitted because I think its irrelevant to the problem***
UITableViewController的代码

import UIKit
import FoldingCell
import LGButton
import TextFieldEffects
import SCLAlertView

class SavedImageFoldingImageCell: FoldingCell, UITextFieldDelegate {

// CLOSED
@IBOutlet weak var enterAGreetingLabelClosed: UILabel!
@IBOutlet weak var savedImageView1Closed: UIImageView!
@IBOutlet weak var savedImageView2Closed: UIImageView!
@IBOutlet weak var openCellButton: LGButton!


// OPEN
@IBOutlet weak var confirmLabelOpen: UILabel!
@IBOutlet weak var englishLabelOpen: UILabel!
@IBOutlet weak var spanishLabelOpen: UILabel!
@IBOutlet weak var savedImageView1Open: UIImageView!
@IBOutlet weak var savedImageView2Open: UIImageView!
@IBOutlet weak var enterAGreetingLabelOpen: UILabel!
@IBOutlet weak var enterAGreetinTextFieldOpen: HoshiTextField!
@IBOutlet weak var barViewOpen: UIView!


// 'Continue' Button
@IBOutlet weak var continueButton: LGButton!

// Hamburger Button
@IBOutlet weak var hamburgerButton: UIButton!










// MARK: - Setting-up Labels


// CLOSED Labels
var enterAGreetingClosed: String = "" {
    didSet {
        enterAGreetingLabelClosed.text = String(enterAGreetingClosed)
    }
}


// OPEN Labels
var englishOpen: String = "" {
    didSet {
        englishLabelOpen.text = String(englishOpen)
    }
}

var spanishOpen: String = "" {
    didSet {
        spanishLabelOpen.text = String(spanishOpen)
    }
}

var enterAGreetingOpen: String = "" {
    didSet {
        enterAGreetingLabelOpen.text = String(enterAGreetingOpen)
    }
}

var confirmOpen: String = "" {
    didSet {
        confirmLabelOpen.text = String(confirmOpen)
    }
}










override func awakeFromNib() {
    barViewOpen.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] // Top right corner, Top left corner respectively
    barViewOpen.clipsToBounds = true
    
    foregroundView.layer.cornerRadius = 10
    foregroundView.layer.masksToBounds = true
    
    super.awakeFromNib()
    // Initialization code
    enterAGreetinTextFieldOpen.delegate = self
}

override func animationDuration(_ itemIndex: NSInteger, type: FoldingCell.AnimationType) -> TimeInterval {
    let durations = [0.26, 0.2, 0.2]
    return durations[itemIndex]
}










@IBAction func enterAGreetingTextFieldEditingDidBegin(_ sender: HoshiTextField) {
    print("@enterAGreetingTextFieldEditingDidBegin -> cell.swift: does nothing as of now.")
}


@IBAction func enterAGreetingTextFieldEditingDidEnd(_ sender: HoshiTextField) {
    
    if sender.text!.isEmpty != true {
        // Activates and shows the 'Continue' button
        continueButton.isEnabled = true
        continueButton.alpha = 1
        
    print("enterAGreetingTextFieldEditingDidEnd@Cell -> cell.swift: activated 'Continue' button because textField contained text after editing ended.")
    } else if sender.text!.isEmpty == true {
        // Deactivates and hides the 'Continue' button
        continueButton.isEnabled = false
        continueButton.alpha = 0.5
        
        print("enterAGreetingTextFieldEditingDidEnd@Cell: deactivated 'Continue' button because textField was empty after editing ended.")
    }
}




// JUST FYI, THIS DOES NOT GET CALLED
private func textFieldShouldReturn(_ textField: HoshiTextField) -> Bool {
    let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
    let savedImageTableVC = storyboard.instantiateViewController(withIdentifier: "SavedImageTableViewController") as! SavedImageTableViewController
    savedImageTableVC.loadViewIfNeeded()

                
        if textField.text?.isEmpty == false {
            savedImageTableVC.liveGreeting = textField.text!
            savedImageTableVC.savedImageTableView.reloadData()
            print(".CELL @textFieldShouldReturn() -> savedImageTableVC.savedImagesArray: \(savedImageTableVC.savedImagesArray).")
                            
            let indexPathRow = textField.tag
            StructOperation.globalVariable.tappedCellIndexRow = indexPathRow
            print(".CELL @textFieldShouldReturn() -> StructOperation.globalVariable.tappedCellIndexRow: \(StructOperation.globalVariable.tappedCellIndexRow).")

            savedImageTableVC.goToSend()
                        
            print("User entered a greeting in enterAGreetingTextField: \(savedImageTableVC.liveGreeting).")
        } else if textField.text?.isEmpty == true {
            savedImageTableVC.liveGreeting = ""
            SCLAlertView().showError("Error", subTitle: "To send an image, a greeting must also be specified.", closeButtonTitle: "Done", timeout: nil, colorStyle: SCLAlertViewStyle.error.defaultColorInt, colorTextButton: 0xFFFFFF, circleIconImage: nil, animationStyle: .topToBottom)
                            
            print("User did not enter a greeting in enterAGreetingTextField.")
        }
    return true
}

}










// MARK: - Actions ⚡️


extension SavedImageFoldingImageCell {

@IBAction func openCellButtonTapped() {
//        print("The open-cell button was tapped (just a downward arrow).")
}

@IBAction func enterAGreetingTextfieldOpenEditingDidEnd() {
//        print("'enterAGreetingTextField' finished editing.")
}

@IBAction func continueButtonTapped(_: AnyObject) {
//        print("The 'Continue' button was tapped.")
}

@IBAction func hamburgerButtonTapped(_: AnyObject) {
//        print("The hamburger button was tapped.")
}

}
import UIKit
import TextFieldEffects
import SCLAlertView
import MessageUI
import FoldingCell
import MLKitTranslate

class SavedImageTableViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate, UITextFieldDelegate, UIContextMenuInteractionDelegate {

@IBOutlet var savedImageTableView: UITableView!


*** Omitted other irrelevant outlets, vars, & constants ***


override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    activityIndicator() // Omitted because nothing regarding the textfield is called here
    refresh() // Omitted ""
    
}

override func viewDidLoad() {
    super.viewDidLoad()
    setup() // Omitted ""; (assigned self to tableview's delegate and dataSource here)
    checkIfSavedImages() // Omitted ""
    getDeadlineInSeconds() // Omitted ""
    
    
    // For deadline countdown timer
    countdownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateCounter), userInfo: nil, repeats: true)
    
    
    // Stops loading spinner and hides view
    self.indicator.stopAnimating()
    self.indicator.hidesWhenStopped = true
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(true)
}



@IBAction func enterAGreetingTextFieldEditingDidEnd(_ sender: HoshiTextField) {
    let cell = savedImageTableView.dequeueReusableCell(withIdentifier: "SavedImageFoldingImageCell") as! SavedImageFoldingImageCell
    
    if sender.text?.isEmpty == true {
        sender.text =  ""
        cell.continueButton.isEnabled = false
        cell.continueButton.alpha = 0.5
//            sender.resignFirstResponder()
    } else if sender.text?.isEmpty == false {
        self.liveGreeting = sender.text!
        cell.continueButton.isEnabled = true
        cell.continueButton.alpha = 1
    }
}

@IBAction func enterAGreetingTextFieldEditingDidBegin(_ sender: HoshiTextField) {
    sender.becomeFirstResponder() // Fixes IQKeyboardManager (rather, allows UITableViewController to properly scroll)
    
    let indexPathRow = sender.tag
    StructOperation.globalVariable.tappedCellIndexRow = indexPathRow
    print("enterAGreetingTextFieldEditingDidEnd()@ViewController -> StructOperation.globalVariable.tappedCellIndexRow: \(StructOperation.globalVariable.tappedCellIndexRow).")
}




//MARK: - TableView Functions

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    guard case let cell as SavedImageFoldingImageCell = cell else {
        return
    }
    
    cell.enterAGreetingClosed = "Enter a Greeting"
    cell.enterAGreetingOpen = "Enter a Greeting"
    cell.englishOpen = "English"
    cell.spanishOpen = "Spanish"
    cell.confirmOpen = "Confirm"
    
    
    // Greeting TextField
    cell.enterAGreetinTextFieldOpen.delegate = self
    cell.enterAGreetinTextFieldOpen.tag = indexPath.row
    
    // Open-cell button (downward arrow)
    cell.openCellButton.tag = indexPath.row
    
    // 'Continue' button
    cell.continueButton.tag = indexPath.row
    cell.continueButton.isEnabled = false
    cell.continueButton.alpha = 0.5
    
    // Hamburger button
    cell.hamburgerButton.tag = indexPath.row
    
    
    // Closed/Open Images (English, Spanish)
    let calculatedIndex = (indexPath.row * 2) + 1
    
    cell.savedImageView1Closed.image = savedImagesArray[calculatedIndex - 1]
    cell.savedImageView2Closed.image = savedImagesArray[calculatedIndex]
        
    cell.savedImageView1Open.image = savedImagesArray[calculatedIndex - 1]
    cell.savedImageView2Open.image = savedImagesArray[calculatedIndex]

    
    
    cell.backgroundColor = .clear
    
    
    
    if cellHeights[indexPath.row] == Constants.closeCellHeight {
        cell.unfold(false, animated: false, completion: nil)
    } else {
        cell.unfold(true, animated: false, completion: nil)
    }
    
    
    
    // Allows recognition of tapping the 'Continue' button by connecting that button's outlet to a newly created function down below a little
    cell.continueButton.addTarget(self, action: #selector(SavedImageTableViewController.continueButtonTapped(_:)), for: .touchUpInside)
    // Allows recognition of tapping the 'open cell' button (just a downward arrow) by connecting that button's outlet to a newly created function down below a little
    cell.openCellButton.addTarget(self, action: #selector(openCellButtonTapped(_:)), for: .touchUpInside)
    // Allows recognition of tapping the 'hamburger' button (just three horizontal lines as a button) by connecting that button's outlet to a newly created function down below a little
    cell.hamburgerButton.addTarget(self, action: #selector(hamburgerButtonTapped(_:)), for: .touchUpInside)
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = savedImageTableView.dequeueReusableCell(withIdentifier: "SavedImageFoldingImageCell", for: indexPath) as! FoldingCell
    let durations: [TimeInterval] = [0.26, 0.2, 0.2]
    cell.durationsForExpandedState = durations
    cell.durationsForCollapsedState = durations
    
    
    return cell
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard case let cell as FoldingCell = tableView.cellForRow(at: indexPath) else {
        return
    }
    
    if cell.isAnimating() {
        return
    }
    
    var duration = 0.0
    let cellIsCollapsed = cellHeights[indexPath.row] == Constants.closeCellHeight
    if cellIsCollapsed {
        cellHeights[indexPath.row] = Constants.openCellHeight
        cell.unfold(true, animated: true, completion: nil)
        duration = 0.5
    } else {
        cellHeights[indexPath.row] = Constants.closeCellHeight
        cell.unfold(false, animated: true, completion: nil)
        duration = 0.8
    }

    UIView.animate(withDuration: duration, delay: 0, options: .curveEaseOut, animations: {
        tableView.beginUpdates()
        tableView.endUpdates()
        
        
        // fix https://github.com/Ramotion/folding-cell/issues/169
        if cell.frame.maxY > tableView.frame.maxY {
            tableView.scrollToRow(at: indexPath, at: UITableView.ScrollPosition.bottom, animated: true)
        }
    }, completion: nil)
    
    // Provide haptic feedback of success
    let generator = UINotificationFeedbackGenerator()
    generator.notificationOccurred(.success)
}

***Rest is Omitted because I think its irrelevant to the problem***

通过简单地将类从UITableViewController->UIViewController切换,我解决了自己的问题。我浏览了IQKeyboardManager的Github页面上的已解决问题,发现由于苹果的UITableViewController自动处理视图和键盘的移动,IQKeyboardManager的开发人员选择忽略UITableViewController中的文本字段。因此,必须将该类更改为UIViewController或其他受支持的类,以使IQKeyboardManager能够识别文本字段