【问题标题】:Lagging Issue in Hindi Language in TableviewTableview 中印地语的滞后问题
【发布时间】:2016-06-11 13:47:23
【问题描述】:

我在 Tableview 中有很多标签和印地语文本。 印地语文本通过 PHP Web 服务获取。但是在tableview中落后太多了。 滚动不流畅。忍受这么多的挂起和滞后。

这是我的cellForRowAtIndexPath 和文本转换为可读格式的代码:

- (UITableViewCell *)tableView:(UITableView *)tableview cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellIdentifier;
    GroupPost *post=(GroupPost*)[[arrMsg objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
    if([post.postType isEqualToString:@"0"]){
        cellIdentifier=@"GroupDetailCustomeCellTextOnly";
    }

    /////////Text Convert in URLDecode and get readble text....

    NSString *unicode=[[post.postContent URLDecode] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

     cell.lblPostContent.text =unicode;

     return cell;
}

//This Function Use For URLDecode....
- (NSString *)URLDecode {
    return [self URLDecodeUsingEncoding:NSUTF8StringEncoding];
}

- (NSString *)URLDecodeUsingEncoding:(NSStringEncoding)encoding {
    return (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL,
                                             (__bridge CFStringRef)self,
                                             CFSTR(""),
                                             CFStringConvertNSStringEncodingToEncoding(encoding));
}

请指导我如何使滚动非常顺畅,并从我的 Tableview 中消除挂起和滞后问题。

【问题讨论】:

  • 在表格视图加载之前。从您的网络服务中创建一个完整的数组,并为数据源使用后台队列!还在主线程更新 UI ......可能它工作顺利。
  • @Pushp 贴一些代码..plz
  • 你在哪里创建你的UITableViewCell?把那个代码sn-p。
  • @DipenPanchasara in view didLoad==> [tblViewList registerNib:[UINib nibWithNibName:@"GroupDetailCustomeCellTextOnly" bundle:nil] forCellReuseIdentifier:@"GroupDetailCustomeCellTextOnly"];
  • 它唯一的注册单元。你在哪里初始化你的细胞?

标签: ios uitableview uilabel


【解决方案1】:
dispatch_queue_t myQueue = dispatch_queue_create("My Queue",NULL);
dispatch_async(myQueue, ^{
    // Perform long running process
    NSMutableArray *unicodeArray = [[NSMutableArray alloc] init];
    for (i = 0; i < arrMsg.count ; i++)
    {
        GroupPost *post=(GroupPost*)[arrMsg objectAtIndex:i];
        NSString *unicode=[[post.postContent URLDecode] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

        [unicodeArray addObject:unicode];
    }
});

使用 unicode 数组作为数据源。试试让我知道发生了什么。将此代码放在 viewDidLoad

dispatch_async(dispatch_get_main_queue(), ^{
        [tableView reload]
    });

将此代码放在 viewDidAppear

【讨论】:

  • 错误进入主线程块=>没有可见的@interface for 'UITableView' 声明选择器重新加载
  • 我在标签中设置我的值,例如,=> cell.lblPostContent.text =unicode;
  • 你在 cellforrowatindex 路径中改变了你的值
  • like ==>cell.lblPostContent.text =[unicodeArray objectAtIndex:indexPath.row]; ???
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-29
  • 1970-01-01
  • 2019-09-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多