Saad
Saad

Reputation: 235

UITableView scrolling not smooth with custom table cell in ios

I am using custom cell.here i load two image and four label. TableView scrolling not smooth.here is my code.

        static NSString *simpleTableIdentifier = @"SimpleTableCell";

        CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
        if (cell == nil)
        {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellSixPlus" owner:self options:nil];
            cell = [nib objectAtIndex:0];
        }
        cell.cellButtonOutlet.tag = indexPath.row;
        [cell.cellButtonOutlet addTarget:self action:@selector(yourButtonClicked:) forControlEvents:UIControlEventTouchUpInside];


        NSManagedObjectModel *device = [self.devices objectAtIndex:indexPath.row];


        long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]];
        long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]];


        cell.nameLabel1.text = [languageName objectAtIndex:index1];
        cell.nameLabel2.text = [languageName objectAtIndex:index2];

        cell.nameLabel3.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceText"]];
        cell.nameLabel4.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"transilateText"]];

        cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]];
        cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]];

        return cell;

Problem solved by increasing cell height

Upvotes: 0

Views: 247

Answers (1)

Sandeep Kumar
Sandeep Kumar

Reputation: 328

comment following line of codes and try again :

long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]];
long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]];

cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]];
cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]];  

If it will work fine then you need to assign images in background queue

Upvotes: 1

Related Questions