Some_random_coder
Some_random_coder

Reputation: 147

Multiple columns and rows in segment control?

Is there a way to make a standard segment control having multiple rows and columns?
As an example(not mine, just got a quick one from google search) http://d1anb8nbe09bpc.cloudfront.net/94/eb/18/94eb1824b32d45df9cde7913e1aa6c15/table___axure_files/u192_normal.gif

But I want to do this with segment control. So imagine from that picture, that 3 columns and 4 rows, which are all segments from a segment control. I managed to rotate the segment control.. but no idea how do i put the segment control inside a uicollection view?

Any ideas?

Upvotes: 0

Views: 1021

Answers (1)

Chris Heyes
Chris Heyes

Reputation: 41

You can achieve this with buttons. Just lay them out the way you want, set up the standard and selected state values. Link all the buttons to a single IBAction method. In that method set for all buttons button.selected = NO and for sender button button.selected = YES.

Alternatively you could write your own UIControl.

Update

To achieve an arbitrary number of toggle using collection view. Set the collectionview up so that it only allows a single selection. This effectively gives you that toggle behaviour you want. To achieve the visual - subclass UICollectionViewCell, override setSelected: and here you can toggle the look of the cell. For further functionality you can implement collectionView:didSelectItemAtIndexPath: in your delegate (usually your View Controller). There are numerous tutorials on UICollectionView.

Upvotes: 1

Related Questions