慢UITableView滚动 [英] Slow UITableView scrolling

查看:76
本文介绍了慢UITableView滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑-----我在英文记录上做了相同的代码滚动速度像往常一样保持快速并且工作正常,但是当我提取阿拉伯数据时,滚动再次变慢。这是阿拉伯数据的问题???

Edit----- i done the same code on english record scrolling speed remain fast as usual and its working fine, but when i am fetching Arabic data scrolling is slow again. is this a problem with arabic data???

我有大约100的记录,我的tableview滚动非常慢。任何人都可以告诉我这个代码有什么问题,以及为什么我会慢速滚动?

I have records of about 100 and my tableview scrolling is very slow. can anyone tell me what is wrong with this code, and why iam getting slow scrolling?

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

    GreetingAppDelegate *appdelegate = (GreetingAppDelegate *)[[UIApplication sharedApplication]delegate];
    DBSetter *product = (DBSetter *)[appdelegate.myrecords objectAtIndex:indexPath.row];    

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16.0];
    }


    CGRect a=CGRectMake(8, 0, 307, 59);
    UIImageView *aImg=[[UIImageView alloc] initWithFrame:a];
    UIImageView *bImg=[[UIImageView alloc] initWithFrame:a];

    //if(indexPath.row%2==0)
    aImg.image=[UIImage imageNamed:@"cell-arrow.png"];


    //else {
    //  aImg.image=[UIImage imageNamed:@"CellHighlight.png"];   
    //}



    bImg.image=[UIImage imageNamed:@"cell-arrow-h.png"];
    [aImg setContentMode:UIViewContentModeScaleToFill];
    [bImg setContentMode:UIViewContentModeScaleToFill];
    cell.backgroundView=aImg;
    cell.selectedBackgroundView=bImg;
    [aImg release];
    [bImg release];


    NSString *tempStr=[NSString stringWithFormat:@"%@",product.tempdesc];

    //int stringlength=[tempStr length];
    //[[tempStr stringByReplacingOccurrencesOfString:@"<Dear User>" withString:@" "] substringWithRange:NSMakeRange(0, 20)];

    //if (stringlength >20) {
    //cell.textLabel.text = [NSString stringWithFormat:@"%@...", [[tempStr stringByReplacingOccurrencesOfString:@"<Dear user>" withString:@""] substringWithRange:NSMakeRange(0, 30)]];
    //}
    //else {
        cell.textLabel.text = tempStr;
    //}


    if(appdelegate.lang==2) 

    {
        [cell setTextAlignment:UITextAlignmentRight];
aImg.transform = CGAffineTransformMakeScale(-1, 1);
        bImg.transform = CGAffineTransformMakeScale(-1, 1);
    }

    return cell;
}


推荐答案

感谢每一位回复......我只是弄清楚自己。我只是使用长度和范围来使它工作。对于可能遇到同样问题的人,我使用的代码如下所示。

Thanks every one for your replies... i just figure out it my self. i just use length and range to make it works. the code that i used is as follow, for the one who might suffer same problem.

NSString *tempStr=[NSString stringWithFormat:@"%@",product.tempdesc];

    int stringlength=[tempStr length];
    if (stringlength >20) {
    cell.textLabel.text = [NSString stringWithFormat:@"%@...", [[tempStr stringByReplacingOccurrencesOfString:@"<Dear user>" withString:@""] substringWithRange:NSMakeRange(0, 30)]];
    }
    else {
    cell.textLabel.text = tempStr;
    }

这篇关于慢UITableView滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆