Set title labels of buttons in table view from an array full of strings

前端 未结 1 523
悲哀的现实
悲哀的现实 2021-01-17 08:22

I was making this table view inside my view controller. The table view was going to have a set of buttons. Now I have an array which contains labels for those buttons, but t

相关标签:
1条回答
  • 2021-01-17 08:32

    Try this -

    [btnProblem setTitle:[btnLabels[indexPath.section] forState:UIControlStateNormal];
    

    instead of this -

    [btnProblem setTitle:[btnLabels[indexPath.row] forState:UIControlStateNormal];
    

    As there are only one row in each section, to access array's object use section number. p.s also uncomment the above line of code.

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