Static Table Cell in Dynamic Table View? - iphone

I'm using Core Data to save my dynamic UITableView (not controller, AFAIK you can't have a static table view in a UITableView). I was wondering if it was possible to add a separate section to my table view with just one static cell inside? I tried looking but I couldn't find anything so far! I just need a point in the right direction.
Thanks!

As Scott says, you have to stay with a dynamic table view.
However, you can have multiple UITableViewCell's (with different reuse identifiers) in your table, so just create two different cells and return the appropriate one, based on the indexPath provided in cellForRowAtIndexPath:.

Unfortunately, a table is either completely static or completely dynamic. If part of your table view needs to be dynamic, you'll have to make the whole table view dynamic and implement the delegate methods for the static cells as well.

Related

How to get height of embedded dynamic UITableView within a static UITableView

I'm trying to create a screen for entering patient information very similar to the contacts edit screen in iOS.
I think the screen should be a static table with cells for simple things like firstname, lastname, etc.
Within the static table would be cells containing embedded tables with dynamic cells. There would be an embedded table for phone numbers, another for street addresses, and another for medical providers, ... Each of these embedded tables could have zero or more entries.
Is embedding dynamic tables in a static table the right way to do this?
I don't know how to get the height of the embedded content so that I can set the height of the static cell.
This is quite an advanced topic that I cannot cover in depth now, but I will try to give you a few pointers on how to proceed.
I would advise against embedding tableviews into other tableviews.
Use a dynamic tableview.
Create a view model that provides an array of objects for the controller to render.
The controller only takes objects from the view model and decides which cells to render (no logic in the controller)
In the view model deal with all the complexities of the data (static content, dynamic sub-arrays, sections, if-else statements, ...)
Build the complex cells (address cell in your example) using for example stack views.
Dealing with multiple fields inside one cell can be tricky, you will have to do some more research on that topic.
There are many tutorials on view model architecture ("mvvm"), google it.
I hope that helps, good luck and happy hacking!

Is "setting" UI implemented by table view in iphone/touch/ipad?

I want my app's setting UI feel consistent with iphone's internal setting UI. It looks like it's implemented by a table view with sections to group the setting items together. Am I correct?
refer to: http://i.stack.imgur.com/XNVyO.png
Is it implemented by a table view with hard coded cells and sections or is it build by interface builder? If it is built by IB, how to design the sections?
thanks
-Leo
you might want to look at something like InAppSettingsKit, an open source framework that duplicates the settings app feel in your application.
if you want to create it yourself you'd just set the ui table view style to UITableViewStyleGrouped
Read up about how UITableView Work, You will need a UITableViewDataSource.
The datasource tells the table how many sections and cells there are in the table view.
Then the UITableViewDelegate will handle any selecte rows:
http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/TableView/TableView.html

iPhone app - some custom UITableViewCell questions

At the moment, I have a settings view in my iPhone app built with Interface builder, it consists of a background image, some text fields, labels and buttons. Because this looks bad, I want to convert the settings view to an UITableView with custom UITableViewCells.
I already tried adding some cells into my settings view's XIB and returning them in the cellForRowAtIndexPath method (with [return myCell];), as written in Apple's tutorial, but this was not working for me - my whole TableView looked strange and it only showed the first cell correctly.
Is it possible to design these custom cells in Interface Builder? Do I have to create an empty XIB for them or can I put them in my view's XIB? And how do I insert them into my TableView?
Thanks in advance,
Yassin
You can absolutely add custom table cells that you built in interface builder. This includes both static cells and Dynamic cells. However without you providing more information the best I can say is "double check the docs and try again." I can only say that it works and it's rather straightforward so it's hard to say what you may have missed. It might be more helpful if you post what you have for the tableView:cellForRowAtIndexPath method.
Since you say you just have some text fields, I would recommend looking at the technique for static row content section of the Table View Programming guide. You probably would want to have each field of your form correspond to a row in a Segmented Table View, it'll make everything look nicer.

iPhone -- customizing a grouped table view in Interface Builder

I am writing an iPhone app. According to the design, it is supposed to contain a lot of grouped table views. In these views, the rows are frequently not similar to each other. For example, on one screen, one row is the name of a task, another is its owner, another is its description, yet another is its history (which is supposed to be an expanding box), and so on. These rows are edited in different ways. For example, the name can be entered free-form, but the owner has to be chosen from a list, which would be brought up in a further table view.
I think doing all of this programatically would drive me batty. What I want is a way to design these screens in IB. But I can't figure out how to get IB to do treat the cells individually. Is that possible?
Thanks.
In Interface Builder you create custom UITableViewCells for each row and then return the appropriate custom cell in – tableView:willDisplayCell:forRowAtIndexPath:. You also need to return the height of each custom cell in – tableView:heightForRowAtIndexPath:.
Within Interface Builder, you create a custom cell just like you would any view. You size the cell and then fill it with subviews. It's best if you create a UITableViewCells subclass for each custom cell that has IBOutlets that connect to each subview. That way you can easily access labels, imageviews, controls etc.

Multiple images per row in UITableView's cell

Is there any sample code that would illustrate how to have multiple images within each row?
Typical apps show a thumbnail to the left side with text to the right. I'd like to do that plus an image to the right of the text.
How would I go about doing this?
In interface builder, simply create a tableview cell that looks like you want. Then create a UITableViewCell subclass that has properties pointing to the elements of the new cell. Set the class of cell to the subclass then add cells of that class to the table in the standard way.
A tableview cell is just a view and you modify it and use it just like any other view.
You'll have to create a custom UITableView cell. Here's an example of using multiple UILabels in one. Here's another.
Pretty easy - follow Apple's documentation to create exactly the cell you want in Interface Builder with as many UIImage or whatever else you like. Look at Table View Programming Guide for details on how to make and load the custom cells - just be careful about performance when you put a lot of visual elements in a table view.