0
내 app을 설정하여 TableView에 셀이 표시되는 ViewController에 셀을 추가 할 수 있지만 셀을 클릭하면 더 많이 표시됩니다. 정보. 여기에 ... 코드입니다삭제하려면 스 와이프 때 tableViewCell을 얻는 방법
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var selectedIndexPath: NSIndexPath? = nil
override func viewDidLoad() {
super.viewDidLoad()
tableView.registerNib(UINib(nibName: "CustomViewCell", bundle: nil), forCellReuseIdentifier: "Cell")
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomViewCell
cell.clipsToBounds = true
return cell
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if selectedIndexPath != nil {
if indexPath == selectedIndexPath {
return 140
} else {
return 38
}
} else {
return 38
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// New
switch selectedIndexPath {
case nil:
selectedIndexPath = indexPath
default:
if selectedIndexPath! == indexPath {
selectedIndexPath = nil
} else {
selectedIndexPath = indexPath
}
}
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
모든 것은 확장하고 삭제 나는 슬쩍 셀을 구성하는 것을 제외하고 셀에 대한 폐쇄하지만 삭제 슬쩍 때 셀이 단지 확장과 함께 잘 작동합니다. Heres는 코드 : 나는 스 와이프하여 삭제 할 때이 같은 셀 확장 할 해달라고
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete") { (action , indexPath) -> Void in
self.editing = false
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let moc = appDelegate.managedObjectContext
moc.deleteObject(self.events[indexPath.row])
appDelegate.saveContext()
self.events.removeAtIndex(indexPath.row)
tableView.reloadData()
}
return [deleteAction]
}
, 어떤 아이디어?
나는 140을 38로 변경하려고 시도했다. 내가 훔 쳤을 때 전혀 확장되지 않겠지 만 코드의 일부가 그것에 영향을 미쳤다고 나는 생각하지 않는다. 셀을 스 와이프하면 정상 크기로 돌아갑니다. –