使用 SwipeCellKit 自定义 TableViewCell
Custom TableViewCell with SwipeCellKit
我对 pod SwipeCellKit 的理解有问题。
我有这个简单的设置(用于检索数据的 Firebase)
我的:
class MyFriendsViewController: UIViewController,UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var MyFriendsTableview: UITableView!
var ref: DatabaseReference!
var MyFriendslist = [MyFriendsModel]()
我的 cellForRowAt 是这样的:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends", for: indexPath) as! MyFriendsTableViewCell
// let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends") as! SwipeTableViewCell
// cell.delegate = self
当我尝试实现 swipeCellKit 时,如果我输入 :
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends") as! SwipeTableViewCell
cell.delegate = self
有人知道如何解锁吗?
谢谢!
只要改变这个:
class MyFriendsTableViewCell: UITableViewCell { ...
给这个:
class MyFriendsTableViewCell: SwipeTableViewCell { ...
我们刚刚继承了 SwipeTableViewCell
class。进行此更改后,您将能够使用 MyFriendsTableViewCell
属性和 SwipeTableViewCell
属性。
更新代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends", for: indexPath) as! MyFriendsTableViewCell
cell.delegate = self
...
cell.yourMyFriendsTableCellProperty = ...
return cell
}
我对 pod SwipeCellKit 的理解有问题。
我有这个简单的设置(用于检索数据的 Firebase)
我的:
class MyFriendsViewController: UIViewController,UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var MyFriendsTableview: UITableView!
var ref: DatabaseReference!
var MyFriendslist = [MyFriendsModel]()
我的 cellForRowAt 是这样的:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends", for: indexPath) as! MyFriendsTableViewCell
// let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends") as! SwipeTableViewCell
// cell.delegate = self
当我尝试实现 swipeCellKit 时,如果我输入 :
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends") as! SwipeTableViewCell
cell.delegate = self
有人知道如何解锁吗?
谢谢!
只要改变这个:
class MyFriendsTableViewCell: UITableViewCell { ...
给这个:
class MyFriendsTableViewCell: SwipeTableViewCell { ...
我们刚刚继承了 SwipeTableViewCell
class。进行此更改后,您将能够使用 MyFriendsTableViewCell
属性和 SwipeTableViewCell
属性。
更新代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomFriends", for: indexPath) as! MyFriendsTableViewCell
cell.delegate = self
...
cell.yourMyFriendsTableCellProperty = ...
return cell
}