新たに追加した「UIViewController subclass」(UITableViewController subclassのチェックを外して生成)にtableViewが必要な場合、
- 生成したUIViewControllerクラスのインターフェースファイル(「.h」ファイル)にプロトコル<UITableViewDataSource>を追加
- Interface Builderでライブラリから「TableView」を「View」に貼付ける
- 貼付けた「TableView」上で右クリックして、「dataSource」を「File's Owner」に結びつける
- 生成したUIViewControllerクラスのメソッドファイル(「.m」ファイル)の任意の位置にUITableViewDataSourceの必須メソッドを記述
UITableViewDataSource必須メソッド(2つ)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
コメントする