Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
No se pudo convertir el valor del tipo 'UITableViewCell' a 'SwipeCellKit.SwipeTableViewCell'

Estoy tratando de usar un pod llamado SwipeCellKit en mi proyecto, donde este pod agrega una clase llamada SwipeTableViewCell. Lo que he hecho hasta ahora es:

  • Cree un controlador de vista para el guión gráfico.
  • Cree una clase UIViewController .
  • Importe SwipeCellKit al archivo Swift.
  • Asigne el controlador de vista a la clase.
  • Agregue una vista de tabla al controlador de vista.
  • Conecte el delegado y la fuente de datos desde la vista de tabla al controlador de vista.
  • Agregue la celda prototipo a la vista de tabla y llámela "celda" por su identificador reutilizable.
  • Cambie la clase de celda a SwipeTableViewCell.
  • Agregue un delegado de vista de tabla al controlador de vista.
  • Agregue la función numberOfRows y cellForRow a mi clase UIViewController.

Esta es la implementación de cellForRow :

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell; return cell; }

Pero recibí un error en let cell = ... , diciendo:

No se pudo convertir el valor del tipo 'UITableViewCell' a 'SwipeCellKit.SwipeTableViewCell'

¿Por qué? ¿Y cómo arreglar esto? Creo que lo he arreglado todo como debe ser. ¿Me he perdido algo?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Lo que resolvió el problema para mí:

En Main.Storyboard (o donde tenga sus vistas), asegúrese de que en todos los lugares donde quiera usar la "celda" reutilizable, en el Inspector de identidad en el panel derecho, tenga lo siguiente:

  • La clase está establecida en SwipeTableViewCell
  • El módulo está configurado en SwipeCellKit .
over 4 years ago · Santiago Trujillo Report

0

Debe crear su propia clase de celda como subclase de SwipeTableViewCell , luego debe implementar el protocolo SwipeTableViewCellDelegate en su ViewController

y por esta linea

 let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell

debe usar el nombre de su clase, que es una subclase SwipeTableViewCell

ejemplo

 let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! MySwipeableCell cell.delegate = self
over 4 years ago · Santiago Trujillo Report

0

Creé el siguiente ejemplo

 import UIKit import SwipeCellKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 4 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell return cell } } class SwipeTableViewCellSubClass: SwipeTableViewCell { override func awakeFromNib() { super.awakeFromNib() // Initialization code } }

establezca la clase para que su vista sea SwipeTableViewCellSubClass.

esto debería funcionar perfectamente para usted. buena suerte

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!