我已經嘗試搜索一些關於如何填充表格視圖的教程,但是我發現的所有教程都是舊的和過時的視頻。我試着從稍微更新的版本開始,並且它不起作用。我有在iOS中填充Tableview單元格6
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[chemarray addObject:@"2"];
[chemarray addObject:@"test"];
[chemarray addObject:@"3"];
[chemarray addObject:@"science"];
}
和
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [chemarray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.textLabel.text = [chemarray objectAtIndex:indexPath.row];
return cell;
}
按照本教程中,運行的時候,它應該在我的數組顯示的項目,但對我來說,這不!有誰知道如何解決這一問題?
你是否將視圖控制器設置爲表視圖的委託?它創建單元格還是不創建單元格? –
它不會創建單元格 – Alexyuiop