Implement UITableViewDataSource and UITableViewDelegate protocols in your view controller .h file.
@interface ThirdViewController : UIViewController
Have an outlet for the UITableView.
@property (retain, nonatomic) IBOutlet UITableView *SMSTableView;
In viewDidLoad, set the tableView's datasource and delegate to self since the viewcontroller implements the protocol.
tableView.delegate = self;
tableView.dataSource = self;
Then, write the cellForRowAtIndexPath method.
It will be getting called.
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
return cell;
}
沒有留言:
張貼留言