Showing some famous quotes and authors with buttons

61 views Asked by At

Hi!!! This is a picture that shows how an App I wanna make looks like.

The view has 2 labels , one for the quote and one for the author , and two buttons for going across of each of them.

It's simple , I would like to have quotes like: "Stay hungry , stay foolish" - Steve Jobs or whatever.

My questions :

1) How to show correctly the different quotes with the correct authors passing 1 by 1 clicking on the buttons?

2) The buttons should show in order the quotes. I mean, 1 position back or 1 position ahead. How to advance 1 by 1 with them?

My current code it's able to display random quotes clicking on 1 button but with no authors (It was only a try). Here is it:

var frasesOcultas : [String] = ["El mundo pertenece a quienes tienen el valor de perseguir sus sueños", "Mantente alocado, mantente hambriento","Un día despertarás y descubrirás que ya no tienes tiempo para hacer las cosas que habías soñado, hazlo ahora","La mente siempre se rinde antes que el cuerpo", "Si puedes soñarlo lo puedes lograr" , "Nos acabamos convirtiendo en nuestras obsesiones" ]




@IBOutlet weak var labelFrases: UILabel!




override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}





@IBAction func previousButton(sender: AnyObject) {

    let fraseAleatoria = Int(arc4random_uniform(6))

    var frase1 = frasesOcultas[fraseAleatoria]

    labelFrases.text = frase1

    self.view.addSubview(labelFrases)



}



@IBAction func nextButton(sender: AnyObject) {





}
1

There are 1 answers

0
mforrest On

Surely you should just keep track of the number of the quote you are currently on and then increment or reduce that depending on which button is pressed?