Graphics Programs Reference
In-Depth Information
Subclassing UITableViewController
Now you're going to write a subclass of
UITableViewController
for
Homepwner
.
For this view controller, we'll use the
NSObject
template. From the
File
menu, select
New
and then
New File...
. From the
iOS
section, select
Cocoa Touch
, choose
Objective-C
class
, and hit
Next
. Then, select
NSObject
from the pop-up menu and enter
Item-
sViewController
as the name of the new class. Click
Next
and then click
Create
on
the next sheet to save your class.
Open
ItemsViewController.h
and change its superclass:
@interface ItemsViewController : NSObject
@interface ItemsViewController : UITableViewController
The designated initializer of
UITableViewController
is
initWithStyle:
,
which takes a constant that determines the style of the table view. There are two options:
UITableViewStylePlain
, where each row is a rectangle, and
UIT-
ableViewStyleGrouped
, where the top and bottom rows have rounded corners. In
ItemsViewController.m
, implement the following initializers.
#import "ItemsViewController.h"
@implementation ItemsViewController
- (id)init
{
// Call the superclass's designated initializer
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
}
return self;
}
- (id)initWithStyle:(UITableViewStyle)style
{
return [self init];
}