Jules
Jules

Reputation: 7774

What options do I have to provide a feature to allow sorting of a UITableView?

I'm quite short on space. My navigation bar is full. Ideally I'm looking for something below the navigation bar which once tapped will change the sort order of the rows in my uitableview.

I'm looking for options ?

Upvotes: 2

Views: 271

Answers (3)

Daniel G. Wilson
Daniel G. Wilson

Reputation: 15055

You could create a really snazzy custom toolbar that appears by tapping a gear shaped button on the navigation bar. It could slide down from under the navigation bar and sit there right below it, and when you finish with it you could send it right back under the navigation bar, hidden.

The advantage of that is your app has a really cool custom toolbar, and all of your buttons are secreted away in a single organized toolbar - the disadvantage being that you actually have to invent one of these.

  • As I'm thinking about it though, if you have buttons that are navigation related taking up all the space - not ones that do stuff - then this probably won't work.

Upvotes: 1

EmptyStack
EmptyStack

Reputation: 51374

One option is to add tableHeaderView to the table view with the buttons which trigger the sorting action. If your table view contains only one section you can add it as section header(better use tableHeaderView).

Adding UISegmentedControl with the segments(for different types of sorting) as the tableHeaderView is an elegant way.

Upvotes: 2

bryanmac
bryanmac

Reputation: 39306

One option (although much less discoverable than items on the navbar) would be to re-sort when components of the cell are tapped. For example, let's say the cell had a picture on the left of a user, a title and a score. As you tapped on each component of the cell, it would sort by that component. Repeated taps on the same cell component would toggle between ascending and descending. That has the downside of intercepting the cell tap and you would only drill in when tapping on an area of the cell that you're not sorting by.

Upvotes: 1

Related Questions