UITableView가있는 위의 UITableView가있는 UIViewController가 하나 있습니다. UISegmentControl이 있습니다. 세그먼트 컨트롤을 누르면 UItableCustomeCell을로드하고 싶습니다.이 구현에서 도움을 받으시겠습니까? 나는 다른 사용자 정의 전지 여기각 UISegmentController마다 다른 사용자 정의 셀 호출
이
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
if (indexPath.row == self.segmentedControl.selectedSegmentIndex == Test1) {
MytestsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MytestsCell"];
if (!cell) {
cell = [[MyBooksCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"MytestsCell"];
}
return cell;
}
else if (indexPath.row == self.segmentedControl.selectedSegmentIndex == tests) {
testCell *cell = [tableView dequeueReusableCellWithIdentifier:@"testCell"];
if (!cell) {
cell = [[TestsCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"testsCell"];
}
return cell;
}
break;
case 1:
if (indexPath.row == self.segmentedControl.selectedSegmentIndex == PTest) {
PTestsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PTestsCell"];
if (!cell) {
cell = [[PTestsCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"PTestsCell"];
}
return cell;
}
break;
}
내가 한 테이블에서 그들의 3를 갖고 싶어하지 않는 코드는 3 가지고 있기 때문에 내가 cellForRowAtIndexPath에 추가하는 방법을 알고, 각 사용자 정의 셀입니다 하나의 세그먼트 컨트롤
미리 감사드립니다!
답장을 보내 주셔서 감사합니다.이 메소드에는 무엇을 작성해야합니까? - (id) dequeueReusableCellWithIdentifier : (NSString *) 식별자 forIndexPath : (NSIndexPath *) indexPath –
아무 것도 할 필요가 없습니다. iOS 6의 UITableView 클래스에 추가 된 메서드입니다. 응답을 보면, 새로운 dequeue 메소드를 사용하여 식별자 문자열을 사용하여 tableview에서 셀을 가져온 다음 반환하는 것을 볼 수 있습니다. – JonahGabriel