Hello. I have a restaurant menu cell with a photo of the dish, price, name and button to add to the basket. After clicking on this button, it should disappear and something like [- 1pcs +] will appear

How to implement correctly: after clicking on the "put in the basket" button, first create another cell with the desired view and after pressing, change it or hide the button (button.hidden = true) and in parallel display the view with my + - buttons

Thank. If the first option is correct, please tell me which methods to use in order to change one cell to another by clicking

Thanks again

Update

Then let me ask you how to find my twist with buttons and label inside the IBAction buttons?

At the view inside which there are two buttons + - and the label assigned the tag - 1

Now implemented so

@IBAction func buttonAddToCart(sender: AnyObject) { var button: UIButton = sender as UIButton // ΠΏΠ΅Ρ€Π΅Π΄Π°Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ sender ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΡƒΡŽ Π² ΠžΠ±ΡŠΠ΅ΠΊΡ‚ΠšΠ½ΠΎΠΏΠΊΡƒ var viewMoreOrLess = button.superview.superview.viewWithTag(1) // Π½Π°Ρ…ΠΎΠΆΡƒ Π²ΡŒΡŽΡˆΠΊΡƒ с ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ +- button.hidden = true // ΡΠΊΡ€Ρ‹Π²Π°ΡŽ ΠΊΠ½ΠΎΠΏΠΊΡƒ viewMoreOrLess.hidden = false // дСлаю Π²ΠΈΠ΄ΠΈΠΌΠΎΠΉ вью с +- } 

Works but alarming - superview.superview

Update 2

didSelectRowAtIndexPath is called when the didSelectRowAtIndexPath clicks a cell and this action expands the full description of the dish, so it is not appropriate.

I put all the actions and outlets into the custom class of my cell UITableViewCell and everything fell into place, everything worked

Thanks @tragvar great.

  • yes)) I was sure that you immediately had a custom class for the cells. - tragvar

1 answer 1

So you can also add UIStepper + UIlabel hidden in the cell (or your + and UIlabel buttons). By clicking on the "put in the basket" do (button.hidden = true), and show hidden. Why do you need another cell?

Update

Sorry, did not notice that you have a swift.

But there should be such a method that you immediately determine which cell you are in, and then you already manipulate the buttons on the index of this cell, you can write your code directly in it, or call the button action into which to transfer the cell index.

override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)