테이블보기에 대한 Lynda.com iOS
자습서를 따르고 있습니다. 우리가 만들고있는 데모는 두 섹션으로 된 테이블 뷰를 생성하기로되어 있습니다. 두 섹션의 데이터는 컨트롤러의 viewDidLoad
메서드 (위임자)의 plist
파일에서 가져오고 아래에서 볼 수 있듯이 두 섹션이 있어야하며 각 섹션에 헤더가 있어야 함을 선언합니다.tableView에서 두 섹션을 선언했지만 단 하나만 나타납니다.
그러나 시뮬레이터에서 실행할 때 첫 번째 섹션 ('iOS 코스'라는 제목 있음) 만 화면에 표시되며 스크롤 할 수 없습니다. web_courses
에 대한 섹션이 나타나지 않습니다. 아래 코드에서 web_courses
섹션이 표시되지 않는 이유를 설명 할 수 있습니까?
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0){
return @"iOS courses";
}else {
return @"web courses";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0){
return courseDetails.count;
}else {
return webCourseDetails.count;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *url = [[NSBundle mainBundle] URLForResource:@"courses" withExtension:@"plist"];
courseDetails = [NSDictionary dictionaryWithContentsOfURL:url];
justCourseNames = courseDetails.allKeys;
NSURL *urlWeb = [[NSBundle mainBundle] URLForResource:@"courses_web" withExtension:@"plist"];
webCourseDetails = [NSDictionary dictionaryWithContentsOfURL:urlWeb];
webCourseNames = webCourseDetails.allKeys;
}
내가 제안한대로 중단 점을 설정했고 해당 함수의 'webCourseDetails' 로컬 변수에'numberOfRowsInSection' 함수에 11 개의 키/값 쌍이 있다고합니다. – BrainLikeADullPencil
시뮬레이터 맨 아래에는 행의 위쪽 절반이 표시되고 뷰는 스크롤하여 스크롤을 내려서 스크롤을 허용하지 않으므로 다른 섹션이있을 수 있습니다. 그러나 어떤 이유로 스크롤 할 수 없습니다. – BrainLikeADullPencil
실제로 비디오에서 작동하더라도 자습서에서 제공하는 코드에서 (컴퓨터에서 실행할 때) 똑같은 일이 발생합니다. – BrainLikeADullPencil