In my tableview, I want to be able to drag only a few cells to the left for some options depending on the condition. Should other cells behave like commitEditingStyle
is disabled, is it possible?
With the code given below, when I can meet the conditions, I can still add work, but still "delete" other cells, how can I get rid of that deleted work Am I Override Funk Tableview (Tableview: UITABEView, ActionForrowoutindexpace IndexPath: NSIndexpath) - & gt; Override Funk Tableview (Tableview: Comment: UIPTABLE Viewing, Commenting System Editing Style: UITWeekWeeklighting Style, RORAT & EXPRESS INDEXPath: NSINXPath) [AnyObject]? {Object = items [indexPath.row] If object.name == "name" {// someAction var addAction = UITableViewRowAction (style: default, titled: "+") {(verb: UITableViewRowAction!, IndexPath: NSIndexPath!) - & gt; Return to zero} [addAction]} return nil}
I have been able to enable and disable actions with the code below but only delete
button with.
override Fnk Teblwu (Teblwu: Uaitibl scene, Snpadnsistm Foreroaetindpep Indekspath: Ansaindakspath) - & gt; UITableViewCellEditingStyle {object = items [indexPath.row] if object.name == "Joyce" {UITableViewCellEditingStyle.Delete return} else {return to UITableViewCellEditingStyle.None}}
< Div class = "post-text" itemprop = "text">
You want a way to determine the editable status based on your data model. For example:
class Message {var Subject: string Weir Title: String Veret Adjetibl: bool Init (theme: string title: string) {self.subject = subject self.title = title Self .isEditable = true}}
With it, you can easily see the tableview: canEditRowAtIndexPath:
representative method. Feedback controller should look something like this:
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {var tableView: UITableView! Messages above [message] // Mark: - tableView function UITableView rep (tableView: UITableView, numberOfRowsInSection section: int) - & gt; Int {return self.messages.count} function tableView (tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) - & gt; Bool}
A more complicated example is a calculation can be an asset but {message = self.messages [indexPath.row] return message.isEditable go} is the overall concept.
No comments:
Post a Comment