1

How to insert a new cell in between UITableViewCells when a cell gets selected from the UICollectionView? Here is what it would look like:

I am trying to create a family tree(pedigree chart).when the parent is selected it shows a Detail and the childs. How to achieve this? Thank You!

Shibili
  • 117
  • 2
  • 11
  • YOURTABLE.beginUpdates() YOURTABLE.insertRows(at: [IndexPath(row: YOURINSERTROWPOSITION, section: 0)], with: .automatic) // that means add here your row before you want to add. like 1 2 3 4 5 what ever YOURTABLE.endUpdates() – Himanshu Moradiya Jun 21 '17 at 10:42
  • Add data inside array which you are returning in numOfRows and reload it.Implement all thing inside didSelectItemAtIndexPath. – Shabbir Ahmad Jun 21 '17 at 10:45
  • @HimanshuMoradiya Thanks for the reply. How to insert a **view** in between two cell? as shown in the above figure? – Shibili Jun 23 '17 at 07:07
  • @Shibili create one tableviewcell or that show your viewcell that white color in your snapshot and when button click at time insert that cell in tableview so your problem solve – Himanshu Moradiya Jun 23 '17 at 07:20
  • @HimanshuMoradiya can you please explain more about this? Thank you! – Shibili Jun 23 '17 at 10:16
  • i want to show your tableview cell Cellrowatindex delegates method that display tableview in that tableview you display collectionview – Himanshu Moradiya Jun 23 '17 at 10:20
  • I have created two different XIB files. One for the Detail and other for the collection view.Both of the cell loads using XIB. @HimanshuMoradiya – Shibili Jun 23 '17 at 10:25
  • then create another xib for your popup view and just load that xib when you need to display on collectionviewcell click – Himanshu Moradiya Jun 23 '17 at 10:31
  • YOURTABLE.insertRows(at: [IndexPath(row: YOURINSERTROWPOSITION, section: 0)], with: .automatic). How to insert that XIB at a perticular index of the table view? @HimanshuMoradiya – Shibili Jun 23 '17 at 10:39
  • just create tableview cellrowatindexpathmethod that inside put one condition for popviewxib cell if you want to display it then write code inside it otherwise return anothercell – Himanshu Moradiya Jun 23 '17 at 10:54

1 Answers1

1
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    (...)
    tableView.insertRows(at: [IndexPaths], with: .top)
}
Michał Kwiecień
  • 2,734
  • 1
  • 20
  • 23
  • When ever a collection view cell is selected a **Detail view** will pop up in between the table view cells as shown in the image above. How to insert a view in between the two cells? @MichałKwiecień . Thanks in advance! – Shibili Jun 23 '17 at 07:12