두 개의 배열을 가지고 있습니다.프로그래밍 방식으로 CustomCell을 만드는 방법은 무엇입니까?
1) nameArray; 2) numberArray;
이러한 배열에는 이름과 숫자가 포함되어 있으므로 nib을 사용하지 않고 테이블 뷰에 이러한 이름과 숫자를 표시하려고합니다. 프로그래밍 방식으로 사용자 지정 셀을 만드는 방법
두 개의 배열을 가지고 있습니다.프로그래밍 방식으로 CustomCell을 만드는 방법은 무엇입니까?
1) nameArray; 2) numberArray;
이러한 배열에는 이름과 숫자가 포함되어 있으므로 nib을 사용하지 않고 테이블 뷰에 이러한 이름과 숫자를 표시하려고합니다. 프로그래밍 방식으로 사용자 지정 셀을 만드는 방법
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"CellIdentifier";
CustomCellName *cell = (CustomCellName *)[tableView dequeueReusableCellWithIdentifier:identifier];
if(!cell) {
cell = [[CustomCellName alloc] initWithStyle:UITableViewStyleDefault reusableIdentifier:identifier];
}
cell.textLabel.text = [nameArray objectAtIndex:indexPath.row];
cell.subtextLabel.text = [numberArray objectAtIndex:indexPath.row];
return cell;
}
의 서브 클래스 (오히려 내 아이폰의 입력에이 모든 아웃)하지만, 코드를 현명하게 사용해야합니다.
textLabel라는 = 속성 이름 귀하의 사용자 정의 셀 클래스 레이블 설정 당신이 당신의 사용자 정의 셀 클래스 레이블 설정 subtextLabel = 속성 이름이 도움이
희망!
UITableViewCell의 하위 클래스 여야하는 새 파일을 만듭니다. 여기서 원하는 곳에 표시 할 수있는 2 개의 레이블을 작성할 수 있습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *theID = @"TableViewCell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:theID];
return cell;
}
가 여기에 CustomCell 내가이 작업을 수행하기 위해 컴퓨터에 아니에요있는 UITableViewCell
위의 코드는 테스트되지 않은 상태입니다