UISEGMENTEDCONTROL moves when a cell in segment 0 clicked and moved to segment 1

Multi tool use
Multi tool use


UISEGMENTEDCONTROL moves when a cell in segment 0 clicked and moved to segment 1



I have to create a segment with 3, segment 0 has a uicollection view when a cell inside the uicollection is clicked it should move to the second segment which is segment 1.. but I have kept one UIVIEW in storyboard which carries the uicollection view in segment 1. So I need to add one more UIVIEW in storyboard. Please help me. I will attach the storyboard for your reference.


uicollection


uicollection


UIVIEW


uicollection


UIVIEW



enter image description here


func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

}



when I click the cell it should move to next segment which is segment 1. for that where I have to code either in didselectmethod or the action part in segmented control.


didselectmethod


@IBAction func segmented_tapped_action(_ sender: Any) {

}





I'm not sure what the question is all about, but have you tried self.segmentedControl.selectedSegmentIndex = 1?
– Andreas Oetjen
Jul 3 at 8:53


self.segmentedControl.selectedSegmentIndex = 1




1 Answer
1


switch segmented_Control.selectedSegmentIndex{

case 0:
if let cell = collectionView.cellForItem(at: indexPath) as? CategorySegmentCollectionViewCell {
self.segmented_Control.setEnabled(true, forSegmentAt: 1)
segmented_Control.selectedSegmentIndex = 1
collectionView.reloadData()
print(cell)
}



this will be the solution. Thanks for your support






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

m3s5SgBbruN TT8DdF98snbMBDagDQ9,bOVxGOGZNi9fe FhI sd,qnAH9LzB nY03X
l3 k0j30

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications