Вы должны сначала взять объект IBOutlet из UITableView в файле интерфейса, а затем связать его с помощью конструктора интерфейса.Установите делегат и источник данных UITableView в свойстве построителя интерфейса.
И выполните в своем проекте следующую кодировку.
В файле .h:
@interface RootViewController : UITableViewController<UITableViewDelegate,UITableViewDataSource> {
IBOutlet UITableView *tblView;
}
В файле .m:
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Настройка количества строк в табличном представлении.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return n;// n for number of row.
}
// Настройка внешнего видаячеек табличного представления.
- (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;
}