- (NSInteger)tableView:(UITableView *)tableViewまずは、これです。これは、リストに表示される項目数(行数)を返すメソッドです。returnしたNSIntegerの数だけ項目が用意されます。引数には、項目を表示するUITableViewインスタンスと、セクションの番号を示すNSIntegerが渡されます。
numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableViewこれは、リストの項目である「セル」を作成し返すものです。リストに表示される各項目は、「UITableViewCell」というクラスのインスタンスとしてUIKitに用意されています。このメソッドでは、リストであるUITableViewインスタンスと、そのセルを表示する場所「インデックスパス」というものを示すNSIndexPathインスタンスというものが引数として渡されます。
cellForRowAtIndexPath:(NSIndexPath *)indexPath;
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※RootViewController.h
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController {
}
@end
※RootViewController.m
#import "RootViewController.h"
@implementation RootViewController
- (void)viewDidLoad
{ [super viewDidLoad];}
- (void)viewWillAppear:(BOOL)animated
{ [super viewWillAppear:animated]; }
- (void)viewDidAppear:(BOOL)animated
{ [super viewDidAppear:animated]; }
- (void)viewWillDisappear:(BOOL)animated
{ [super viewWillDisappear:animated]; }
- (void)viewDidDisappear:(BOOL)animated
{ [super viewDidDisappear:animated];}
- (NSInteger)numberOfSectionsInTableView:
(UITableView *)tableView
{ return 1; }
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{ return 0; }
// Customize the appearance of table view cells.
- (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;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)
indexPath
{
/* コメントアウトされている */
}
/* コメントアウトされているメソッド
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {}
- (BOOL)tableView:(UITableView *)tableView
canEditRowAtIndexPath:(NSIndexPath *)
indexPath {}
- (void)tableView:(UITableView *)tableView commitEditingStyle:
(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {}
- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)
fromIndexPath toIndexPath:(NSIndexPath *)
toIndexPath {}
- (BOOL)tableView:(UITableView *)tableView
canMoveRowAtIndexPath:(NSIndexPath *)indexPath {}
*/
- (void)didReceiveMemoryWarning
{ [super didReceiveMemoryWarning]; }
- (void)viewDidUnload
{ [super viewDidUnload]; }
- (void)dealloc
{ [super dealloc]; }
@end
| << 前へ | 次へ >> |