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

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
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) {
}
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.
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