-1

dynamic number of uibuttons in uitableviewcell with sections

Hey guys I want to implement a UI like the one in the link above. The tableview has cells with sections and each section has a different number of uibuttons from the other. The number of sections and the text on the buttons are got from server data. Each section can either have one or two or three buttons at each cell depending on the number of data return and the length of the text. I'm implementing this without the use of storyboard or interface builder using Swift4.2 and Xcode10.

1 Answers1

0

Please use collectionView in tableViewCell.

Set the collection view cell count according to the button count.

It may helps you. Thank you.

Sanjukta
  • 1,057
  • 6
  • 16
  • hey i'm trying out this method and it's coming through. I have a small issue though. How do i detect the button tap in the uicollectionviewcell which is inside the uitableviewcell. i'm trying to implement it using delegates and protocols pattern. – Bob Sira Sira Jan 22 '19 at 11:16
  • please set the button tag in cellForRowAtIndexPath method of collection View. – Sanjukta Jan 22 '19 at 11:27
  • The tag will be tableViewSectionNumber + collectionViewItemNumber. So that each button can be a unique tag. Thank you – Sanjukta Jan 22 '19 at 11:28
  • Ok. let me try implementing it first. – Bob Sira Sira Jan 22 '19 at 14:36
  • Just tried out the method you told me but i have a few issues.This is my tableviewcell https://gist.github.com/bobsira/6a7c2b48092925be77c0c45e6df12098, this is my collectionviewcell https://gist.github.com/bobsira/36ff17e2a32322d84cb2016298970d91 and this my view controller https://gist.github.com/bobsira/9b19ccc7df70cb93daf573c9ed914715. In the last part of my view controller, i'm still having problems with the indexpath of the button tapped. – Bob Sira Sira Jan 23 '19 at 08:20
  • Please follow my answer in your new question. – Sanjukta Jan 23 '19 at 11:41
  • thanks i've managed to hack it. but i had to come up with a little twerks. – Bob Sira Sira Jan 23 '19 at 13:44
  • Please accept my two answer with press the tick mark. So other user can get help. Thank you – Sanjukta Jan 23 '19 at 13:56