iOSアプリケーションを持っている人は、テーブルビューのセルをスワイプしてそのセルをお気に入りページのテーブルビューに追加したいと思っています。お気に入りにセルを追加するコアデータを持つテーブルビュー
アプリの終了後にお気に入りが保存されるように、コアデータを使用する必要があります。
助けていただけたら幸いです!
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let favorite = UITableViewRowAction(style: .Normal, title: "Favorite") { (action, indexPath) in
// share item at indexPath
self.editing = false
print("Favorited \(indexPath.row)")
}
favorite.backgroundColor = UIColor.greenColor()
return [favorite]
}
これはお気に入りのページのために私のコードです:
は、これは私がこれまでに細胞スワイプアクションの持っているものです。
var favorites : [String] = []
override func viewDidLoad() {
super.viewDidLoad()
favorites = vars.favs
self.tableView.reloadData()
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return favorites.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let object = favorites[indexPath.row]
cell.textLabel!.text = object
return cell
}
は、あなたがこれまでにやっている私たちを示していただけますか? – penatheboss
私はこれまでのところセルのスワイプアクション設定しか持っていません。 – Jacksmackod
テーブルビューを使用している場合は、テーブルビューの一部の機能が必要です。私たちにそれらを表示 – penatheboss