嗨,我一直在使用解析和快速製作應用程序,並試圖刪除解析以及在屏幕上的單元格。我主要在這裏嘗試了一切,但它不起作用。請幫忙。繼承人的代碼:刪除表格視圖單元格與解析swift
import UIKit
class TableViewController: PFQueryTableViewController {
// Sign the user out
@IBAction func signOut(sender: AnyObject) {
PFUser.logOut()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("SignUpInViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
}
@IBAction func add(sender: AnyObject) {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("TableViewToDetailView", sender: self)
}
}
// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
// Configure the PFQueryTableView
self.parseClassName = "Posts"
self.textKey = "nameEnglish"
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery {
var query = PFQuery(className: "Posts")
query.orderByAscending("nameEnglish")
return query
}
//override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! PFTableViewCell!
if cell == nil {
cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
}
// Extract values from the PFObject to display in the table cell
if let nameEnglish = object?["nameEnglish"] as? String {
cell.textLabel?.text = nameEnglish
}
if let capital = object?["capital"] as? String {
cell.detailTextLabel?.text = capital
}
return cell
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using [segue destinationViewController].
var detailScene = segue.destinationViewController as! DetailViewController
// Pass the selected object to the destination view controller.
if let indexPath = self.tableView.indexPathForSelectedRow {
let row = Int(indexPath.row)
detailScene.currentObject = (objects?[row] as? PFObject)
}
}
override func viewDidAppear(animated: Bool) {
// Refresh the table to ensure any data changes are displayed
tableView.reloadData()
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.reloadData()
tableView.reloadInputViews()
}
}
這裏沒有任何代碼試圖刪除任何東西 – Paulw11
我知道我問我怎麼做,因爲一切嘗試不對應。任何想法如何做到這一點? @ Paulw11 –
你想要刪除哪個單元格 - 它是如何識別的? – CoolPenguin