how to random placement of UIButton and value

前端 未结 8 1266
南方客
南方客 2021-01-28 22:48

i have a question view and will show 4 answers, only 1 are correct.

but i do not want the same button to be always the correct answer.

i will like to know how do

相关标签:
8条回答
  • 2021-01-28 23:21

    create your own class with these 4 buttons. In this class you can store the positions of your buttons. then you can add a member function (something like the following) which will draw them:

    -(void)drawButtonsWithIncorrectAtIndex:(int)index
    
    0 讨论(0)
  • 2021-01-28 23:27

    I would suggest do not change the position of buttons rather what you can do is change the currentTitle property of the buttons randomly and once the user clicks the button ; you can get the currentTitle of the button and check if it is the correct answer or not.

    0 讨论(0)
提交回复
热议问题