2015-09-18 56 views
1

我寫了這個代碼編輯的行樣式(雨燕1.2 - 6.4的Xcode)更新的tableView碼 - 2.0

func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle 
{ 


    let edit = UITableViewRowAction(style: .Normal, title: "Edit") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in 

     let abb: AnyObject = self.frc.objectAtIndexPath(indexPath) 
     let editingView = self.storyboard?.instantiateViewControllerWithIdentifier("editingViewController") as! editingViewController 
     editingView.abbediting = abb 
     self.presentViewController(editingView, animated: true, completion: nil) 
     print("Edit Tapped") 

     print("Edited Button Clicked") } 
    edit.backgroundColor = UIColor.lightGrayColor() 

    let delete = UITableViewRowAction(style: .Normal, title: "Delete") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in 

     let abbDel = self.frc.objectAtIndexPath(indexPath) as! NSManagedObject 
     self.con?.deleteObject(abbDel) 



     print("Delete Button Clicked") 
    } 
    delete.backgroundColor = UIColor.redColor() 


    return [delete,edit] 


} 

我還設置了一些行動,但現在經過我已經更新到7.0的Xcode和Swift 2.0,我一直在收到錯誤,告訴我返回UITableViewCellStyle。

任何機構可以幫助我更新我的代碼,以便與Swift 2.0一起使用嗎?

回答

0

我認爲你的代碼屬於editActionsForRowAtIndexPatheditingStyleForRowAtIndexPath需要返回該行的編輯樣式,例如UITableViewCellEditingStyle.Delete。這是您點擊編輯按鈕時顯示的樣式。