uitableview - How to update a UILabel with UIButton in custom cell in Swift? -


After

I am trying to implement a counter as a using UILabel + and - UIButtons be able to refer to the line using addTarget tag for the I button for custom room, although I'm not sure how to update the label, press a button Add or subtract every time you go.

I cell.drinkQtyLabel.text directly addDrink is to access the function but my research delegates it clearly does not work Pointing to use, but I am not skilled enough with Xcode to know what to do with this information.

Here is a screen shot of cells:

iphone6 ​​custom room

The custom cell.swift :

  Import UIKit class ProductListTableViewCell: UITableViewCell {@IBOutlet var Peynam label: UILabel! = UILabel () @IBOutlet var drinks label: UILabel! = UILabel () @IBOutlet var drinksilge label: UILBL! = UILabel () @IBOutlet var drink drink label: UILBL! = UILabel () @IBOutlet var Peacolic label: UILBL! = UILabel () @Iboutlet Weak var subtractDrinkButton: UIButton! = UIButton () @IBOutlet Weak var addDrinkButton: UIButton! = UIButton () required init (coder aDecoder in: NSCoder) {super.init (Coder: aDecoder)} override the init (style: UITableViewCellStyle, reuseIdentifier: String) {super.init (style: style, reuseIdentifier : reuseIdentifier)} override function awakeFromNib () {super.awakeFromNib () // initialization code} setSelected function overrides (selected: bool, animated: bool):}   

and cellForRowAtIndex method:

  Override Closure The tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) - & gt; UITableViewCell {Cell: ProductListTableViewCell = tableView.dequeueReusableCellWithIdentifier ("Cell", forIndexPath: indexPath) drinks ProductListTableViewCell as: PFObject = self.productListData.objectAtIndex (IndexPath.row) PFObject var volume = 1 cell.drinkNameLabel.alpha = 0 cell as as .drinkVesselLabel.alpha = 0 cell.drinkSizeLabel.alpha = 0 cell.drinkPriceLabel.alpha = 0 cell.drinkQtyLabel.alpha = 0 cell.drinkNameLabel.text = drink.objectForKey ( "name")? NSString as cell.drinkVesselLabel.text = drink.objectForKey ("vessel")? NSString as cell.drinkSizeLabel.text = drink.objectForKey ("Size")? NSString cell.drinkPriceLabel.text = drink.objectForKey ("value") as? NSString cell.drinkQtyLabel.text = string (volume) UIView.animateWithDuration (0.5, Animation: {cell.drinkNameLabel.alpha = 1 cell.drinkVesselLabel.alpha = 1 cell.drinkSizeLabel.alpha = 1 cell.drinkPriceLabel.alpha = 1 cell. drinkQtyLabel.alpha = 1}) cell.addDrinkButton.tag = indexPath.row cell.drinkQtyLabel.tag = indexPath.row cell.addDrinkButton.addTarget (self, action selector ( "addDrink:"), forControlEvents: UIControlEvents.TouchUpInside) return cell} addDrink (this is UIButton) function {println ( "added drinks in a row \ (sender.tag)" // update cell.drinkQtyLabel.text}}  

pseudo code that What do I do for cell at indexPath (sender.tag) {cell.drinkQtyLabel.text = integer (cell.drinkQtyLabel.text) + 1: {:

  ारoho addDrink (UIButton this might want something like :)}}  

but I know this is not a solution!

< / Html>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -