2015-03-07 3 views
1

В моей программе я пытаюсь реализовать функцию удаления удаленных объектов в UITableViewCells, но кнопка удаления не появляется, даже если ячейка действительно перемещается так, как должна при прокрутке. Кто-нибудь знает, почему?Кнопка удаления не отображается в UITableViewCell

Вот мой код:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 

    var cell = tableView.cellForRowAtIndexPath(indexPath) as resultsCell 

    otherName = cell.usernameLbl.text! 
    otherProfileName = cell.profileNameLbl.text! 
    self.performSegueWithIdentifier("goToConversationVC", sender: self) 

} 


override func viewWillAppear(animated: Bool) { 
    self.navigationItem.hidesBackButton = true 
} 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return resultsUsernameArray.count 
} 

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 
    return 120 
} 

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    var cell:resultsCell = tableView.dequeueReusableCellWithIdentifier("Cell") as resultsCell 

    cell.usernameLbl.text = self.resultsUsernameArray[indexPath.row] 
    cell.profileNameLbl.text =  self.resultsProfileNameArray[indexPath.row] 

    resultsImageFiles[indexPath.row].getDataInBackgroundWithBlock { 
     (imageData: NSData!, error:NSError!) -> Void in 

     if error == nil { 

      let image = UIImage(data: imageData) 
      cell.profileImg.image = image 

     } 
    } 

    return cell 

} 


@IBAction func logoutBtn_click(sender: AnyObject) { 

    PFUser.logOut() 
    self.navigationController?.popToRootViewControllerAnimated(true) 


} 

func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 
     return true 
    } 

// called when a row is moved 
func tableView(tableView: UITableView, 
    moveRowAtIndexPath sourceIndexPath: NSIndexPath, 
    toIndexPath destinationIndexPath: NSIndexPath) { 
     // remove the dragged row's model 
     let val = friends.removeAtIndex(sourceIndexPath.row) 

     // insert it into the new position 
     friends.insert(val, atIndex: destinationIndexPath.row) 
} 

func tableView(tableView: UITableView, 
    commitEditingStyle editingStyle: UITableViewCellEditingStyle, 
    forRowAtIndexPath indexPath: NSIndexPath) { 
     switch editingStyle { 
     case .Delete: 
      // remove the deleted item from the model 
      friends.removeAtIndex(indexPath.row) 

      // remove the deleted item from the `UITableView` 
      resultsTable.editing = resultsTable.editing 
      resultsTable.editing = true 

      self.resultsTable.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) 
     default: 
      return 
     } 
} 
func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle { 

    return .Delete 

} 

ответ

0

Ваш UITableView слишком велик, поэтому кнопка удаления вне экрана