2012-07-24 3 views
0

을 만들 수 있습니다. 이보기 컨트롤러의 기본보기 외에도 matchView이라는 또 다른보기가 있습니다..xib 파일보기 내가 해결하는 방법을 모르는 큰 문제가 새로운 인스턴스

내 주요보기에는 일치 목록이있는 테이블보기가 있습니다. 이 표보기에서 을 사용하고 싶지만 addSubview:matchView으로 전화하면 가장 최근의 정보가이보기를 채 웁니다.

매번이보기의 새 인스턴스를 만들려면 어떻게해야합니까?

감사합니다.

편집 : 내 자신의 문제를 해결했습니다. matchViewController 인 다른 클래스를 만든 다음 매번 cellforrowatindexpath에 만들어서 [cell addSubview : matchView]로 사용했습니다. 어쨌든 당신의 도움에 대한

덕분에 ..

답변

0

당신은 동적으로 테이블의 각 행에 대해 matchView을 만들어야합니다.

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

    static NSString *CellIdentifier = @"CellIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
             reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    UIView *matchView = [[[UIView alloc]init]autorelease]; 
    [matchView setFrame:CGRectMake(0, 0, width_of_your_table, height_of_your_table_cell)]; 
    //add here, in your matchView whatever content you need to be displaied 
    [cell addSubview:matchView]; 
    return cell; 
} 
관련 문제