다음 코드와 일치하는지 확인하십시오.
class TableviewController:UITableViewController{
override func viewDidLoad() {
super.viewDidLoad()
var isMultipleSelectionActive = false
var selectedItems: [String: Bool] = [:]
tableView.allowsMultipleSelectionDuringEditing = true
tableView.setEditing(true, animated: false)
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let selectedItem = items.objectAtIndex(indexPath.row)
//add to selectedItems
selectedItems[selectedItem] = true
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let selectedItem = items.objectAtIndex(indexPath.row)
// remove from selectedItems
selectedItems[selectedItem] = nil
}
func getStatusOfSelectedItems() {
for item in selectedItems {
println(item)
}
}
//You should override shouldPerformSegueWithIdentifier and return false if isMultipleSelectionActive is true
override func shouldPerformSegue(withIdentifier identifier: String?, sender: Any?) -> Bool {
if let identifierName = identifier {
if identifierName == "NameOfYourSegueIdentifier" {
if isMultipleSelectionActive {
return false
}
}
}
return true
}
}
감사를 선택하는 데 사용이 코드. 그러나이 코드는 내가 필요한 소스를 찾지 못했습니다. segue가 작동하지 않는 경우에만 여러 선택이 잘 작동합니다. 편집 모드에서 다중 선택에서 segue로 이동하지 못하게 할 방법이 있습니까? –
당신이 어떻게 segue의 코드를 보여줄 수 있습니까 ?? –
내 코드를 어떻게 보여줄 수 있습니까? 내가 초보자이기 때문에 잘 모른다. 컨트롤 + 마우스 왼쪽 버튼으로 스토리 보드에서 셀을 드래그하여 세부 정보 페이지로 드래그 한 다음 쇼를 선택하여 세그먼트를 만들었다. –