Newbie TableView challenges - iphone

I am building an app that requires a tableview control so that users can select multiple rows and act upon them in some way. I find it easy to load my data and display it using the UITableViewController but it seems when I do it this way I am unable to place any other controls on the page, such as a toolbar to give the user some actions to perform on the selected rows. I can place a toolbar control on the form in the storyboard, but it doesn't render in the emulator.
Using a UIViewController and placing a TableView on it seems to come with its own set of confusing challenges (that will make total sense once I conquer them).
Is there any advice for a smooth way of getting a table view with toolbar controls? Thanks!

don't use a TableViewController. Use a Standard ViewController, then add a UITableView to it, and adjust the size. This way you will be able to do whatever else you want on that view without limiting yourself to the tableView only functionality.
When you do this make sure you add the datasource and delegate to the connected table. Then add cellForRowAtIndex, number of sections, number of rows, and whatever other delegate methods you need for your table.
Good luck

Is there any advice for a smooth way of getting a table view with toolbar controls?
Yes there are few ways to accomplish this, one way would be adding a footerview to your tableviewcontroller check these
http://developer.apple.com/
UIButtons on tableFooterView not responding to events
Easier way to add this is using storyboard.
Just drag and drop a view in to your tableviewcontroller, then you can adjust the views size and put anything from objects menu to inside of the view.
Now the problem with that is view will not be stable position at the bottom of the page like a tabbar. Lets say you have only 1 row in your tableview, footer view will go up just below that 1 row, lets say you have hundreds of items in your tableview toolbar will be at the bottom of the rows.
The other solutions for your problem would be either create a custom view and adding it to current view or window (this is little bit adbance),but if you want this just google it.
Or just as you said, create a viewcontroller and put a uitableview inside. Dont forget to add <UITableViewDelegate,UITableViewDataSource> to your .h file and then you can call UItableview delegate methods.\
Good Luck.

Related

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.

ContentViewController design decisions for UIPopoverController

I'm trying to do something similar to the Yelp filter on the iPad. It looks like this:
I'm trying to figure out what the best way to do this. It looks very neat, like it's two sections in a UITableView, with each row doing something different. The first Sort Results By is just a UISegmentedControl, the second is some custom control that has multiple selections for the UISegmentContrl, and the Neighborhoods button acts like a UINavigationController, pushing another viewController onto the stack, that hides all the current info in the pic, and has a back button at the top. I was wondering how someone would go about building this. When I first see this, I would
1) create the first UISegmentedControl in the .xib
2) create the second custom control in code (saw a post on SO about how to create a segment control with multiple selections
3) have the Neighborhoods button allocate a new UINavigationController with the rootViewController being the new class I show.
4) add the appropriate "Sort Results By" and "Narrow Results By" UILabels in .xib
5) draw the rounded rects in the code behind in viewDidLoad or something
That's how I would approach it. I'm not sure if that's a good way to approach it or not. I am open to people's suggestions! Thanks a bunch.
I would do it with a grouped table view. Each of those bubbles is a separate cell. You could do all of that with Interface Builder. Just design each cell as a separate item, set up IBOutlets for them, and return the appropriate nib object in your cellForRowAtIndexPath method. You also need to return the proper height of each cell in the heightForRowAtIndexPath method.

How to fix the header and first row in a UITableView

I´m new trying to make some apps using objective c, so I´ve an idea using uitableview but I don't imagine how can I get this.
I´m trying to do something like you do in a spreadsheet where you have a fixed header and the first column too
So when scroll the uitableview vertically the header will stay visible at top of the table and rows will change
And finally when you scroll in horizontal direction the first cell of the row will stay visible and will change the header depending of how you scroll the uitableview
I hope you could give me an idea how to get this, because I don't imagine how to do this, also I don´t have a lot of experience with this programming language.
Thanks!
In a non-grouped table, section headers "stick" at the top of the table as the table scrolls. You can provide a custom UIView (or sub-class thereof) for a section header through the delegate method –tableView:viewForHeaderInSection:. This header view could be created on-the-fly programmatically or loaded from a NIB file. Either way, you can have it contain whatever you want, even update it as the app runs (provided you have given yourself access through ivars or class variables to the views contained in your header view.) If you go this route, you'll want to be clever about allocating resources that comprise this view, so that you are not constantly allocating new resources! This delegate method can be called frequently, and on all but the first call you could simply return the previously created (but updated as and if necessary) header view.
UITableView isn't designed to do this, although I am sure you could figure out some way eventually.
My approach would be to use a fixed UIView of some sort (possibly a UILabel, etc) in a UIViewController's nib as the header/locked cell, and add the UITableView under that. You couldn't then use a UITableViewController, but would have to implement the delegate and dataSource methods in your UIViewController, and use a UISwipeGestureRecognizer to pick up the gestures from the tableView and update the other views.
I've done this by adding a UIView that mimics the first cell in my table. In my case I am using a subclass of UITableViewCell, but that is perhaps not relevant. Normally this view is hidden with an alpha of 0.
If you view controller is the delegate of the UITableView then it will also be the delegate for the inherited UIScrollView. So in your view controller you can implement scrollViewDidScroll. When the scrollView's contentOffset is positive I set my custom view's alpha to 1 (I also do some small size tweaks to make sure there is a perfect match), and when the contentOffset returns to 0 or negative, I reset the alpha back to 0.
prepend the first row of data in your array to what ever in the first row is your headings, put the text in bold with attributed text, It wont be sticky but you will have headings...

Is it possible to put one UITableView over another UITableView in InterfaceBuilder?

I know I can use codes to add UITableView one by one.
[self.view addSubview:tableview1];//
[self.view addSubview:tableview2];//
I hope to do the same thing in InterfaceBuilder, when I drag one UITableView onto another one, the new one always pushes the old one to the bottom, rather than just stays over the old one of UITableView.
Welcome any comment
Thanks
If you have a parent view that will contain your tableviews then you shouldn't have any problem. If you're trying to place them directly in a window then I could see a problem. If things aren't lining up the way you want you can always change their position via the Size Inspector or by nudging them with the arrow keys (shift-arrow key moves in 10 pixel increments).
Why anyone would want a tableview on top of another tableview escapes me.
Your parent view should be a subclass of uiviewcontroller and your xib should have the root view as a uiview and not uitableview.
I used two overlapping table views to show two different contents on the same view, which could be toggles using a segment switch. Apparently my client requirements were vague enough that I couldn't just filter out data like how the phone app displays all calls/missed calls list.

Rearranging rows in uitableview

I've an application in which each row contains an uiimageview and an uibutton. I have created them using custom cells, uitableviewcells. The button is to trigger the method, uiimagepickercontroller to pick an image from the library and show it in the imageview. I need that any user who uses the application can rearrange the rows as they wish so that they decide the order of the photos. code here
Reordering of rows in a tableview is pretty straightforward, you just need to implement a few methods of the UITableViewDataSource Protocol and your good to go. Have a look at the Table View Programming Guide for info & code.
http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageReorderRow/ManageReorderRow.html
You could show an Edit button in the navigation bar if your using a navigation controller, which switches the table view to edit mode, causing the reordering control to be shown. This edit button could be changed to done, once the table is in edit mode of course. Don't forget to set the showsReorderControl property of the cell to YES. From then on, it's just a matter of implementing the right methods.