开发者

iPhone UITableViewController custom layout

I'm a beginner in iPhone programing. My first app is a UITableViewController but now I would like to experiment a little bit. The idea is to create a custom layout that would look like this:

The layout:

---------------------
Image     |    Button开发者_如何学C     
---------------------
UICalendar
---------------------
UITableView
---------------------
Button     |   Button
---------------------

QUESTION 1: As you can see I would like to add some additional UI elemnts. All the tutorials I've seen describe UITableViewController as a single UITableView (no other UI elements included in a controller). So my question would be is it possible to extend UITableViewController to have that kind of layout? What is a proper way to do it?

QUESTION 2: For UITableViewController I don't use XIB file but some people do. Why would I use XIB file when creating a UITableViewController? What are the benefits? What is the best practice?

UPDATE: Actually what I'm thinking of is to have a separated controller for UICalendar (UICalendarController) and UITableView (UITableViewController). I just don't know how to implement that.

Thx.


The standard approach for the kind of thing you're trying to do is not to subclass UITableViewController or to use a XIB file to define the interface for the view connected with a UITableViewController, but instead to use a UIViewController with a XIB file that happens to include a UITableView in it.

You'll have to implement the UITableViewDataSource and UITableViewDelegate protocols in your UIViewController subclass, but this is not difficult.

UITableViewController is a somewhat brittle and limited class, unfortunately. It's not hard to create your own classes that use UITableViews, but it's unintuitive to many people that the right approach to doing so doesn't start with UITableViewController.


Check out the Tapku library. It comes complete with a Calendar / Table.


In iPhone, you can create every control by programming or you can use XIB. XIB makes the work simple by using native features of the control. If you want to extend the control and its features, create custom classes and create them manually.

Coming to UITableView, is your representation for one cell? Else you can create custom cells and add them to the table view. For creating custom table view cells you have to extend your class from UITableViewCell and implement them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜