我在普通 UIViewController 中使用了以下代码以及其他一些内容,表格视图位于视图的底部:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [names count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"namen";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSString *cellValue = [names objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
还有一个名为 names 的 NSMutableArray(有 4 个对象)