I’m just having a play with my first App, mainly using the various blocks taught in the lectures in different ways.
If you nest a button press inside a button press will it create a ‘second click on same button functionality’? Is there a better way of doing this?
e.g. @IBAction func dealTapped(_ sender: Any) {
// Some code blah blah - for example ‘start something’
@IBAction func dealTapped(_ sender: Any) {
//Some different code - for example 'stop something'
}//Close the inner
}//Close the outer
Is there a good way to tie in a delay to a button press to the duration of a wav file? For example:
i. User presses button
ii. Wav file plays
iii. On completion of the wav file, the ‘next thing happens’
(iv. if you couldn’t be bothered waiting you can click again and it skips the delay…see Q1 above)
Thanks for any ideas, I don’t (think) I need code solutions, just some ideas and signposts where to look further.
late thanks for the reply, can I ask for help on this one again please.
I have three buttons on the page, all linked to the VC on a single IBAction with a switch against tag numbers 11,22, 33
Button one works fine but buttons 2 and three don’t work. Is it obvious why in the following code? I’ve double checked they are correctly linked
@IBAction func ButtonPress(_ sender: UIButton) {
switch sender.tag {
case 11:
do {
print("button 1 pressed")
currentPageIndex = data[currentPageIndex].b1Destination!
soundPlayer.playSound(desiredSound: "page\(currentPageIndex)button1")
displaySt()}
case 22:
do {
print("button 2 pressed")
// need check button is active needs an if statement
currentPageIndex = data[currentPageIndex].b2Destination!
soundPlayer.playSound(desiredSound: "page\(currentPageIndex)button2")
displaySt()}
case 33:
do {
print(“button 3 pressed”)
// need check button is active needs an if statement
currentPageIndex = data[currentPageIndex].b3Destination!
soundPlayer.playSound(desiredSound: “page(currentPageIndex)button3”)
displaySt()}