-2

I'm a beginner in coding and I have this question:

Example, I have 4 different labels with their own messages.

Label1 - you should read the rules
Label2 - congratulations you read the rules
Label3 - now you can join us
Label4 - welcome aboard

I want to be able to do something like this:

Label1 is shown, swipe right > label2 appears > swipe right > label3 appears > swipe right > label4 appears
I also want to be able to swipe left and return to the previous label.

Ex.
label1>label2>label3

2
  • UICollectionView with paging enabled would be a pretty simple solution... but beyond that this question is unclear/too broad.
    – nhgrif
    Jun 23, 2015 at 23:40
  • I'll try the collectionview, I'll let you know how it plays out, thanks!
    – Falek
    Jun 24, 2015 at 1:32

1 Answer 1

0

You could keep each label in an array, create a counter and in the swipe method increase or decrease de counter value to select the corresponding label with the array index of the counter.

Like so:

Swipe right:

counter+=1 currentLabel = labelsArray[counter] as! UILabel

Swipe left:

counter-=1 currentLabel = labelsArray[counter] as! UILabel

But why not use a collectionview instead? You can make it paged and it'll be something that the users are more used to.

1
  • Like I said I'm brand new to swift and coding, counter sounds like a plan but I'll try the collectionview and let you know how it works, thanks!
    – Falek
    Jun 24, 2015 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.