Objective c 如何在不使用dequeueReusableCellWithIdentifier的情况下创建UITableview单元格

Objective c 如何在不使用dequeueReusableCellWithIdentifier的情况下创建UITableview单元格,objective-c,iphone,xcode,uitableview,Objective C,Iphone,Xcode,Uitableview,您可以使用创建一个 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Cell *cell = (ChannelViewTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; NSStr

您可以使用创建一个

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    Cell *cell = (ChannelViewTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];


    NSString *channelName;
    channelName= [NSString stringWithFormat:@"Enter Channel %ld Name", (long)indexPath.row+1];
    indexPathRow= indexPath.row+1;
    return cell;

}
[UITableViewCell alloc]initWithStyle:reuseIdentifier:]
但正如@MuraliMohan和@Larme所说,我们希望通过避免创建不必要的单元来提高性能

方法很简单,假设您有100个单元格要显示。由于设备屏幕太小,您一次最多只能向用户显示15个单元格,如果不进行消隐,您将生成100个单元格并显示15个单元格。dequeing所做的是,当一个单元格离开屏幕时,操作系统会将其重新用于下一个要显示的单元格,因此内存中只有16个单元格,而不是100个


基本上,只需继续进行消隐,但如果您想在测试应用程序中尝试生成大量单元格而不消隐,以查看性能如何下降;)

告诉我为什么要创建而不使用它?为什么不使用“出列”?这就是优化。若你们遇到问题,可能是因为你们做错了什么。解释一下,我们可以提供适当的帮助。谢谢,我知道这会影响性能。但我只需要6个单元格。我相信,即使只有6个单元格,也建议deque,因为如果没有人可用,操作系统会负责创建单元格,并且您不会因dequeing而失去或获得任何东西,最终由您决定使用什么。hmmmmm:):)
[UITableViewCell alloc] initWithStyle:<#(UITableViewCellStyle)#> reuseIdentifier:<#(nullable NSString *)#>]
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"TableViewCell" forIndexPath:indexPath];

    cell.NumberLabel.text =[NSString stringWithFormat:@"Enter Channel %ld Name", (long)indexPath.row+1];
    cell.Name.tag = indexPath.row;

    NSString *dicKey = [NSString stringWithFormat:@"%ld", (long)indexPath.row];

    if (self.cellTextFiledValues[dicKey])
        cell.channelName.text = self.cellTextFiledValues[dicKey];
    else
        cell.channelName.text = @"";

    cell.selectionStyle =NO;
    return cell;
}

- (void)resetTableview{

    self.cellTextFiledValues = [NSMutableDictionary dictionary];
    [self.channelViewTableView reloadData];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    totalChannelCount =[self.datacount.text intValue];
    NSString *dicKey = [NSString stringWithFormat:@"%ld", (long)textField.tag];
    [self.cellTextFiledValues setObject:textField.text forKey:dicKey];
    [self.myTableview reloadData];


}