使自定义单元格可以滑动(没有UITableViewController)

时间:2016-08-22 13:08:39

标签: swift uitableview uiviewcontroller

所以我有一个UIViewController,里面有一个表视图,这就是为什么像这样的大多数问题不适用于此的主要原因。我想让我的单元格可以刷卡,然后可以删除它们等。

我该怎么做?

到目前为止我尝试的是:

#user input data with factor class
userDF = structure(list(Var1 = structure(1:6, .Label = c("", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "c(\"B1\", \"B1\")", "c(\"B3\", \"B4\")", "c(\"B4\", \"B2\")"), class = "factor"), Freq = c(2538L, 633L, 458L, 328L, 135L, 56L)), .Names = c("Var1", "Freq"), row.names = c(NA, 6L), class = "data.frame")
userDF
#  Var1 Freq
#1      2538
#2   B1  633
#3   B2  458
#4   B3  328
#5   B4  135
#6   B5   56

str(userDF)
#   'data.frame':   6 obs. of  2 variables:
#$ Var1: Factor w/ 12 levels "","B1","B2","B3",..: 1 2 3 4 5 6
#$ Freq: int  2538 633 458 328 135 56

#Since userDF had no multiple values, adding them here
newDF = structure(list(Var1 = structure(1:6, .Label = c("B1,B2,B3", "B4,B5", "B6,B7,B8", "B3", "B4", "B5", "B6", "B7", "B8", "c(\"B1\", \"B1\")", "c(\"B3\", \"B4\")", "c(\"B4\", \"B2\")"), class = "factor"), Freq = c(2538L, 633L, 458L, 328L, 135L, 56L)), .Names = c("Var1", "Freq"), row.names = c(NA, 6L), class = "data.frame")
newDF
#      Var1 Freq
#1 B1,B2,B3 2538
#2    B4,B5  633
#3 B6,B7,B8  458
#4       B3  328
#5       B4  135
#6       B5   56


#Make a copy of the dataset
copyDF = newDF

#Var1 is of class factor which is not amenable for string operations,hence convert to character class
copyDF$Var1 = as.character(copyDF$Var1)

#Split each row, unlist and retain only first value

copyDF$Var1 = sapply(strsplit(copyDF$Var1,","),head,1)

copyDF
#  Var1 Freq
#1   B1 2538
#2   B4  633
#3   B6  458
#4   B3  328
#5   B4  135
#6   B5   56

}

override func viewDidLoad() {
super.viewDidLoad()
   self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

override func setEditing(editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
self.tableView.setEditing(editing, animated: animated)

但是它们不能用这种方法进行扫描,并且没有任何事情发生。也没有编辑按钮。

0 个答案:

没有答案