我有一个 TableViewController
,其中有一些单元格。这些单元格具有不同的背景颜色和文本。在测试应用程序时,它们没有问题,但我需要向 TableViewController
添加一个类,因此我转到“自定义类”选项卡并输入该类,之后,我的 TableViewController
只是加载空。这是为什么?
只有当我改变类(class)时才会发生这种情况。
最佳答案
在您的自定义类中,您需要实现如下数据源:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.yourArray.count;}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
customCell *cell = [self.myTableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textlabel.text = @"hi";
return cell;}
关于ios - 更改 TableViewController.swift 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33460215/