2014-09-04 2 views
0

저는 UITableView를 사용하고 있습니다. 이름, 작은 설명 및 엄지 손가락 URL 이미지가 표시됩니다. 나는 username (Name 배열)과 잘 작동하는 것을 기반으로 클래스에 대한 색인을 보여줄 수있다.UITableView 이름 배열에 따라 이미지 배열, 설명 배열을 인덱싱하거나 정렬합니다.

그러나 내 다른 배열 (설명 배열) 및 엄지 URL 이미지 (이미지 배열) 올바르게 데이터를 표시하지 않습니다. 그들은 새로운 섹션을 위해 스스로 반복하고 있습니다.

내가 원하는 것 : 내가 배열을 A에서 Z로 정렬하고 색인을 보여 주면. 다른 모든 배열은 같은 방법으로 정렬되어야합니다.

지금은 이미지 배열과 설명 배열이 새로운 섹션에서 반복됩니다.

도와주세요.

-(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; 
     } 
+0

cellForRowAtIndexPath에 대한 코드는 무엇입니까? – gran33

+0

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]; 행에 올바른 이름이 표시됩니다. –

+0

진짜야? 질문을 수정하십시오 :/ – gran33

답변

0

나는 한 번 비슷한 문제에 직면 해있다. 반복은 UITableViewCell의 재사용으로 인해 발생합니다.

UILabel 및 UIImageView의 값을 위 함수의 첫 번째 줄로 지운 다음 코드를 실행 해 볼 수 있습니다.

관련 문제