RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


More Table View Tricks for the iPhone : Page 3

Go beyond the basics of the iPhone Table View with examples for grouping rows into sections, displaying an index on the side, and adding a Search Bar.


Changing the Style of the Table View

So far, the Table View has been showing rows in plain format (i.e., rows of data separated by horizontal lines). Besides this style, the Table View also allows you to display sections of rows in groups, visually.

In Interface Builder, edit the RootViewController.xib file, select the Table View, and open the Attributes Inspector window. In the Style property (see Figure 7), select Grouped. Save the file.

When you press Command-R to test the application again, you will notice that all the rows are displayed in groups (see Figure 8).

Figure 6. Searching the Table View: The Table View will display all the rows matching your search string.
Figure 7. Modifying the Style of the Table View: In the Style property, select Grouped.
Figure 8. Displaying the Rows in a Table View in Visual Groups: When you test the application, you will notice that all the rows are displayed in groups.

What Have You Learned?

In this article, you have seen how to group rows of data in a Table View into sections and then add an index to the right side of the screen so that users can directly jump to a particular section in the table. In addition, you also learned how to implement search functionality in a Table View, a feature that is very useful for large number of rows. Hopefully, you have found this Table View series useful.

Wei-Meng Lee is a Microsoft MVP and founder of Developer Learning Solutions, a technology company specializing in hands-on training on the latest Microsoft technologies. He is an established developer and trainer specializing in .NET and wireless technologies. Wei-Meng speaks regularly at international conferences and has authored and coauthored numerous books on .NET, XML, and wireless technologies. He writes extensively on topics ranging from .NET to Mac OS X. He is also the author of the .NET Compact Framework Pocket Guide, ASP.NET 2.0: A Developer's Notebook (both from O'Reilly Media, Inc.), and Programming Sudoku (Apress). Here is Wei-Meng's blog.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date