0
하위 뷰가있는 UITableView를 만들고 내가 찾은 튜토리얼을 사용하려고합니다. 그러나 테이블에 데이터를 표시 할 수 없으며 오류가 없습니다.왜이 하위보기 UITableView 데이터를 표시하지 않습니다?
코드를보고이 코드가 어떻게 작동하는지 힌트를 줄 수 있는지 물어보고 싶습니다.
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {
CGRect CellFrame = CGRectMake(0, 0, 300, 60);
CGRect Label1Frame = CGRectMake(10, 10, 290, 25);
CGRect Label2Frame = CGRectMake(10, 33, 290, 25);
UILabel *lblTemp;
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];
//Initialize Label with tag 1.
lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
lblTemp.tag = 1;
[cell.contentView addSubview:lblTemp];
[lblTemp release];
//Initialize Label with tag 2.
lblTemp = [[UILabel alloc] initWithFrame:Label2Frame];
lblTemp.tag = 2;
lblTemp.font = [UIFont boldSystemFontOfSize:12];
lblTemp.textColor = [UIColor lightGrayColor];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
cell = [self getCellContentView:CellIdentifier];
UILabel *lblTemp1 = (UILabel *)[cell viewWithTag:1];
UILabel *lblTemp2 = (UILabel *)[cell viewWithTag:2];
//First get the dictionary object
// NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
NSArray *array = [[NSArray alloc]initWithObjects: @"One", @"Two", @"Three", nil];
NSString *cellValue = [array objectAtIndex:indexPath.row];
lblTemp1.text = cellValue;
lblTemp2.text = @"Sub Value";
[cellValue release];
return cell;
}
Michael, unbelivable 나는 잘못된 번호를 가졌고, 내가 그것을 바꿨을 때 작동한다. 감사! 이것은 n00b로서의 삶입니다 .-) – PeterK
다행 이군요! –