How to Create SMS Ballon iPhone Table View

I was working on incorporating an "sms ballon" type view for a client and while doing some research on the best, and different, ways to implement the functionality I came across a great tutorial, but thought it could be cleaned up just a little bit which should make your FPS increase and I fixed some memory leaks.  I wasn't able to run any performance tests on it so I would welcome ANY feedback how to improve the code.

The key to making the "ballon" background grow and shrink based upon the amount of text is using:

UIImage *balloon = [[UIImage imageNamed:self.imgName] stretchableImageWithLeftCapWidth:24 topCapHeight:15];

If someone has any advice on how to make the font look better please let me know.

Create Custom Sized UITableView with Header and Footer Views

I am currently working on a photo gallery/slideshow app and one of the requirements is for the main gallery listing page to have static header and footer that shows the app name, contact information and adverts.  The logical first method of attack is to just setup a UITableViewController subclass, slap some views and subviews to the table view header and footer and get on with the day.  However, the table itself should scroll, but the "header" and "footer" views should remain stationary.  My first approach, I found out quickly, did not work.  Surprisingly, there are a lot of people having issues with custom sized uitableviews in general and the discussions that I saw online didn't provide a very straight forward solution so I decided to create one.

The first big problem that most people run into is that they can't seem to resize the uitableview no matter what frame size they set.  It doesn't matter if you do it programmatically or through Interface Builder it still takes up the ENTIRE screen.  That is because they have subclassed UITableViewController.  To be honest I am not sure that happens "under the covers", but the custom frame sizes/locations are ignored.  You must make your controller a subclass of UIViewController and then add your UITableView as a subview to the your controllers view.

For example:

At this point your frame size and height will be respected.

In my example I setup a simple UINavigationController project with two controllers.  The first has a header view, footer view and uitableview.  The second "detail" controller just has a UILabel with placeholder text.  Everything is built programmatically so that you can adjust frames and positions easily as well as any other customizations you would like.  Comments/suggestions are always appreciated.

Download Project

Displaying Data on the iPhone with Index UITableView

It is forgone conclusion that if you need to present a large amount of data with a UITableView then you should do so using an index and index sections.  As with most tutorials that I have read on this topic, the scenarios used got me 80% of the way.  In my humble opinion, the solutions where either over engineered or they didn't apply to my use case.  Hopefully this tutorial/sample project will bridge the gap.

The tutorial that I got the most from is: iPhone Development: Creating Native Contacts like screen.

One of the biggest hurdles that I had to over come, that was different from the contacts tutorial, was that I wasn't using a database and therefore didn't have a predefined sub-result set for each character.  I was having to do the opposite.  I had to iterate over my result set, array of states, grab the first letter from each item, check to see if there was already a dictionary key that existed for that letter and proceed accordingly.

Logic Flow
Iterate over states
Get the first letter of that particular state
Check to see if there is a key in the objectsForCharacter dictionary
   - YES: add the state string to the arrayOfNames array and then set the arrayOfNames to the objectsForCharacter dictionary for the appropriate key
  -  NO: remove all objects from the arrayOfNames array and add the firstLetter to the arrayOfCharacters.  Then proceed on to the above "YES" steps
Once all the states have been "proceed" then reload the table data

Final Model
Though it sounds some what complicated with all the arrays, dictionarys, etc. once you break it down to a visual model then the code is easier to comprehend.

[[objectsForCharacters objectForKey:@"A"] objectAtIndex:0]; // Alabama
[[objectsForCharacters objectForKey:@"A"] objectAtIndex:1]; // Alaska
[[objectsForCharacters objectForKey:@"A"] objectAtIndex:2]; // Arizona
[[objectsForCharacters objectForKey:@"A"] objectAtIndex:3]; // Arkansas

Download Example Project (comments/enhancements are welcomed)
IndexedTable.zip