nib에서 UITableViewCell을로드하는 데 문제가 있습니다. 나는 애플의 문서를 사용했지만 어디서 잘못 될지 모르겠다. IB를 통해 생성 된 UITableViewCell에는 5 개의 UIlable이 포함됩니다. 펜촉은 완벽하게로드되지만 문제는 라벨의 텍스트가 자동으로 다른 것으로 스크롤 될 때입니다. 다음은 indexpath에있는 행에 대한 셀 코드입니다. 내가 어디로 가고 있는지 알려주세요.nit에서로드하는 UITableViewCell에 문제가 있습니다
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
int rowNo = [indexPath row];
NSLog(@"Row No:%d",rowNo);
Transfer *tempTransferRecord =(Transfer*)[self.transferInformation objectAtIndex:rowNo];
seasonYear.text=tempTransferRecord.seasonYear;
longName.text=tempTransferRecord.longName;
transactionDate.text=tempTransferRecord.transactionDate;
toTeam.text=tempTransferRecord.toTeam;
fromTeam.text=tempTransferRecord.fromTeam;
/*
static NSString *MyIdentifier = @"MyIdentifier2";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier] ;
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"PlayerTransfers" owner:self options:nil];
cell=transfersInfoCell;
self.transfersInfoCell=nil;
}
*/
static NSString *CellIdentifier = @"MyIdentifier2";
static NSString *CellNib = @"PlayerTransfers";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
// perform additional custom work...
return cell;
}
Interface Builder의 'UITableViewCell' 파일의'File 's Owner' 객체가 위의 코드를 작성한 클래스로 설정되어 있는지 확인하십시오. 또한 현재로드 된 버전보다 주석 처리 된 셀로드 버전을 사용합니다 용도; 테이블 뷰가있는 클래스에'transfersInfoCell' 속성을 추가하고이를 테이블 뷰 셀의 인터페이스 정의에 연결하십시오. 당신이 정의한 @property가 명시 적으로 ('assign') 아니라면,'transfersInfoCell = nil' 전에'self.'도 제거해야합니다. – darvids0n
나는 모든 것을 모두 준비했습니다. IB의 식별자는 MyIdentifier2이고 @property는 (비 원자, 할당)입니다. 테이블에 문제가 생기고 스크롤 할 때 UItableviewcell의 텍스트가 바뀝니다. – slonkar