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

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 ?

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.

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.

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.

Related

How to build this screen in iOS?

I'm new to iOS development and am trying to build something like the screen below:
If I was doing it in Android, I can easily build the above UI in a few minutes. However, I don't know how to go about it with iOS.
I understand that the whole ViewController can be embedded in a navigation controller, which produces the title bar above. What about the bottom part though? I'm thinking of using something like a grouped UITableView but I'm not sure, since every cell will have very different contents:
A search bar, perhaps a subclassed UISearchBar, which I also don't know how to customize--the Search button at the right is required but isn't in the default UISearchBar. When the user taps on it, the UISearchBar must be translated to the navigation bar, no need to display a UITableView of suggested results. I don't know how to do that, too.
A button that, when tapped, flies in a modal from the bottom (I imagine it to be another ViewController with a grouped UITableView), to allow the user to choose from defined locations. Once selected, the modal closes and the button text is replaced with the selected location. This sounds much easier to do.
A header ("Item categories") and the list of categories, which may change in number. If the parent isn't a grouped UITableView, I think this part can be a UILabel and a non-scrolling UITableView with a height that changes depending on how many cells it has. If there are plenty table cells that don't fit given the screen's height, everything below the navigation bar can be scrolled vertically. That, I also don't know how to do.
If anyone can just guide me to what native iOS components I can use to build the above screen, and maybe a couple of tutorials to the things I just said I don't know how to do, I'd appreciate it.
You said it right .All the basic info you need is with you.
To build a searchbar like that i dont think you have to subclass it.
Bottom comprises of tableview.
Actually these Questions are seperately available in SO itself.So search seperately for your needs and you can achieve whatever you want
One basic principle : You cant achive anything by just thinking.Trying and get to it and if you have any issues look forward at it.All the issues will have an answer on the way.
Lots of components you need there.. Search Bar, UIPickerView and UITableView. I would like to give you some pointers.
1) You can refer http://www.appcoda.com/how-to-add-search-bar-uitableview/ for Search bar
2) When clicking on the Button, you can bring up a UIPickerView instead of another controller. For that you can refer http://www.techotopia.com/index.php/An_iOS_5_iPhone_UIPickerView_Example
3) You can use a normal Tableview with a single section, configure the section header to display Item categories.
You are asking too much to ask how to do every component of your UI. I will just answer a little.
Yes, a grouped table view is a good design. I am using a grouped table view for varying types of input. I have an actual table, with rows that can be added, and deleted, and contain an editable text area. Then I have three groups that only really show one piece of content each: two are sliders and one is a switch.
For choosing the location, pushing another view controller on your navigation stack would be the more typical way to handle it. You will save some effort that way, with some buttons and behaviors built in, but a modal view controller is not much harder. I'm not sure if you can make a navigation view fly in vertically, but does your app have to be frame-for-frame identical to the android version?

UITableview with UIPageControl?

I am in the making of a restaurant "step by step" ordering app, where I want to list the menu (appetizers, main course etc) in a tableview with the ability to organize the menu contents with a UIPagecontrol. Something similar to the eat24 app way of doing it or how the weather forecast app is constructed.
I already have the tableview set up, now I just need to implement this, which I hope you will help me with or guide me in the right direction, for me to accomplish this :). Would I need to setup a tableview for each of the categories or would it be possible to just update one tableview with the needed information, by swiping to the left or use arrows in a toolbar in the picture? What would the best way to add a toolbar like the one picture (white ring), using the storyboard -> resize tableview and drag the image in or to set it up programmatically?
Option 1 - Updating your tableView
You may update your dataSource so it reflects the state of the "new" tableView. Than you call reloadSections:withRowAnimation: by using UITableViewRowAnimationRight or UITableViewRowAnimationLeft, depending of whats fitting at the moment. This will feel like scrolling to a new tableView. For swiping you could use a UISwipeGestureRecognizer.
Option 2 - Using a scrollView with multiple tableViews
If you want it a little bit easier just setup three tableViews and throw them in a UIScrollView with paging enabled.
PageControl
Of course you need to add and setup a UIPageControl, if you want to show those dots.
Regarding the UI:
You can setup everything in your Storyboard. The background, the arrow buttons, the UIPageControl, you can even add the UISwipeGestureRecognizer within the Storyboard.

How can I animate this custom view transition in my iPhone app?

This is a tricky question to explain, but basically I have an app with a home screen with a bunch of circular icons on it. When the user taps on an icon, it pushes a table view onto the navigation stack. When an icon is tapped on the home screen, I want the tapped icon to stay on top of the table view as it scrolls in, and then drop onto the table view in the cell that represents it. All the other icons, however, should stay below the incoming table view, like normal. Here's a quick diagram I whipped up...
I'm about to begin researching this, I just wanted to quickly post this question in case anyone has some ideas about how I can approach this. Thanks so much for your wisdom!
Oh thats soo easy!!!
I'll try to explain my solution:
You need two sets of icons.
One set lays on Home View, second is exact location, but as a subview on main window (by default - hidden)
Once You select a button, and want to push a list - You un-hide corresponding window subview icon, and with delay - animate / shrink it to tableView corresponding location.
Once animation is finished - hide icon (instant hide will not be noticeable, as this icon will be positioned/scaled to precisely reassemble icon in tableview), and move it to default position/scale (still hidden).
That's it.
This is pretty simple, and can be done without adding second instances of your buttons. You'll use the view hierarchies z-index for this.
When you add the table view as a subview of the main view don't use addSubview, use:
[self.view insertSubview:table belowSubview:button];
Button^ will represent the button that you want to stay on top, and for your other buttons, you just have to make sure that they are lower on the stack. This way, when the table flies in, it can keep going past the button but the button will stay above it.
You can also use:
[self.view insertSubview:table atIndex:5];
On all of these buttons and the table to have total control over each objects z-index.

How to specify width, flexible space and/or position between UITabBarItems in UITabBar?

I am working on a project when client wants UITabBar lookalike toolbar (icons and titles) at the bottom of some views.
The tab bar needs to have 1 item at the left, empty space, and then 2 items at the right.
Do I have to use 2 extra UITabBarItems (and put them at second and third position) and hide and disable them to accomplish this, or is there a more straightforward solution?
I would like to not to use UIToolBar for this as customizing its height is a pain and causes unexpected behavior in some cases (especially when one uses modal view controllers).
I think you have the right idea. Customizing UITabBar to do stuff out of the ordinary is often quite hard and it is better to just write your own. But in your case you should be able to just as you proposed. One way would be to add the view controllers directly in IB and then set title to an empty string and untick enabled for the second and third view controller.

Disclosure Indicator and Detail Disclosure

I have a table view cell, which is acting like button, performing some action without additional user interface presentation, then it will update the same cell with results of action. What type of accessory would be appropriate for such cells?
I would like to know in which cases I should use the subject types.
If you are keeping the cell in place, without any navigation, but will update the contents of the cell I don't think you need any disclosure accessory there. The flash as the cell is selected and deselected - and of course the change in the cell's visible content - should be enough. It would be more misleading in my opinion to show a disclosure indicator, with its implications of navigation, and then to remain in place.