简体   繁体   中英

UITableView indexing or sorting image array , description array according to name array

I'm using UITableView. I'm displaying Name , small description and thumb url image. I'm able to show indexing for the class on the basis of username (Name array) and its working fine.

But my another arrays (description array) and thumb URL image (Image array) are not displaying data correctly . They are repeating themselves for new sections.

What i want : If i sorted an array from A to Z and showing indexing. All other array should be sorted same way.

right now image array and description array are repeating for new section.

Please help.

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

{

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    NSArray *listData =[self.tableContents objectForKey:

                        [self.sortedKeys objectAtIndex:[indexPath section]]];

    UILabel *lbl1 = [[UILabel alloc] init];

    lbl1.frame =   NSArray *listData =[self.tableContents objectForKey:

                        [self.sortedKeys objectAtIndex:[indexPath section]]];

    UILabel *lbl1 = [[UILabel alloc] init];
    lbl1.frame = CGRectMake(95, 02, 225, 25);
    lbl1.text = listData[indexPath.row];CGRectMake(95, 02, 225, 25);
    lbl1.text = listData[indexPath.row];


    UILabel *lbl2 = [[UILabel alloc] init];
    lbl2.frame = CGRectMake(95, 25, 230, 15);
    lbl2.text = date_array[indexPath.row];   //this one is not working

     return cell;
      }

I have faced a similar issue once. The repetition is caused by the reusing of UITableViewCell.

You can clear the values of the UILabel and UIImageView as the first line of the above function and then try to run the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM