UITableview 滚动不流畅

发布于 2025-01-04 10:37:31 字数 1239 浏览 1 评论 0原文

我的应用程序中有 UITableView &已通过创建任何类文件正常创建了表格视图单元格。 在我的表格单元格中,我添加了 UITextview,因为我的 UITableView 是“滚动不顺畅”。 在我注释文本视图代码或用文本字段/标签替换文本视图之后,表格视图滚动得尽可能平滑。

谁能告诉我为什么会发生这种情况? 提前致谢。

这是我在表中添加文本视图的方法:

    UITextView *txtview = [[UITextView alloc]
    initWithFrame:CGRectMake(93.0,36.0,190.0,94.0)];            
    txtview.backgroundColor = [UIColor clearColor];
    txtview.text = [NSString stringWithFormat:@"%@",strText];
    txtview.contentInset = UIEdgeInsetsMake(5 ,0 ,0 ,0); 
    txtview.textColor = [UIColor colorWithRed:221.0/255.0 green:249.0/255.0
    blue:250.0/255.0 alpha:1.0];   
    [cell.contentView addSubview:txtview];
    [txtview release];

这是我的单元格生成代码:

    UITableViewCell *cell = [tableView
                            dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (!cell) 
        cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 
              reuseIdentifier:CellIdentifier]autorelease];
    else
    {
      NSArray *arraySubviews = [cell.contentView subviews];

        for (UIView *views in arraySubviews)
        {
            [views removeFromSuperview];

        }
    }

I have UITableView in my application & have created tableview cell normally with creating any class file.
In my table cell i'm adding UITextview due to which my UITableView is " not scrolling smoothly ".
After I comment textview code or replaces textview with textfield/Label then tableview scroll as smoothly as it should .

Can anyone tell me why this is is happening?
Thanks in advance.

Here is how i'm adding textview in table :

    UITextView *txtview = [[UITextView alloc]
    initWithFrame:CGRectMake(93.0,36.0,190.0,94.0)];            
    txtview.backgroundColor = [UIColor clearColor];
    txtview.text = [NSString stringWithFormat:@"%@",strText];
    txtview.contentInset = UIEdgeInsetsMake(5 ,0 ,0 ,0); 
    txtview.textColor = [UIColor colorWithRed:221.0/255.0 green:249.0/255.0
    blue:250.0/255.0 alpha:1.0];   
    [cell.contentView addSubview:txtview];
    [txtview release];

Here is my Cell generation code :

    UITableViewCell *cell = [tableView
                            dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (!cell) 
        cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 
              reuseIdentifier:CellIdentifier]autorelease];
    else
    {
      NSArray *arraySubviews = [cell.contentView subviews];

        for (UIView *views in arraySubviews)
        {
            [views removeFromSuperview];

        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难忘№最初的完美 2025-01-11 10:37:31
cell =(UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];  

        if (nil ==cell) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier] autorelease];    
            UITextView *txtview = [[UITextView alloc]
                                   initWithFrame:CGRectMake(93.0,36.0,190.0,94.0)];            
            txtview.backgroundColor = [UIColor clearColor];
            txtview.tag = 15;

            txtview.contentInset = UIEdgeInsetsMake(5 ,0 ,0 ,0); 
            txtview.textColor = [UIColor colorWithRed:221.0/255.0 green:249.0/255.0
                                                 blue:250.0/255.0 alpha:1.0];   
            [cell.contentView addSubview:txtShout];
            [txtview release];
        }
        UITextView *txtview = (UITextView*)[cell.contentView viewWithTag:15];
        txtview.text = [NSString stringWithFormat:@"%@",strText];
cell =(UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];  

        if (nil ==cell) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier] autorelease];    
            UITextView *txtview = [[UITextView alloc]
                                   initWithFrame:CGRectMake(93.0,36.0,190.0,94.0)];            
            txtview.backgroundColor = [UIColor clearColor];
            txtview.tag = 15;

            txtview.contentInset = UIEdgeInsetsMake(5 ,0 ,0 ,0); 
            txtview.textColor = [UIColor colorWithRed:221.0/255.0 green:249.0/255.0
                                                 blue:250.0/255.0 alpha:1.0];   
            [cell.contentView addSubview:txtShout];
            [txtview release];
        }
        UITextView *txtview = (UITextView*)[cell.contentView viewWithTag:15];
        txtview.text = [NSString stringWithFormat:@"%@",strText];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文