이상한 시나리오입니다. tableview의 행을 클릭하면 프레임을 조정하여 부모 중첩 뷰의 섹션 헤더 머리글 바로 아래에 다른 nestedviewcontroller를 시작하는 nestedViewController를 만들었습니다. 자, 두 번째 중첩 된보기에 다른 기능을 추가하려면 UIviewController (tableview에 사용자 정의 셀이 있음)를 childviewcontroller로 추가했습니다. 이제 viewController의 셀을 클릭하면 어떻게 든 첫 번째 NestedViewController의 TableView Delegate가 호출됩니다 !!! 그러나 현재 존재하는 뷰는 두 번째 NestedViewController에 childViewController로 추가 한 UIViewController입니다.중첩 된 환경에서 부모의 부모보기 컨트롤러의 tableview 대리인에 액세스하는 childviewcontroller의 셀 누르기
내가 두 번째 NestedViewController에있는 UIViewController를 추가하는 방법은 다음과 같습니다
이- (void)pushViewController:(UIViewController *)viewController {
//1. The current controller is going to be removed
// [self willMoveToParentViewController:nil];
[viewController willMoveToParentViewController:self];
//2. The new controller is a new child of the container
[self addChildViewController:viewController];
//3. Setup the new controller's frame depending on the animation you want to obtain
CGRect containerRect = CGRectMake(0, self.view.bounds.size.height ,
320.,
self.view.bounds.size.height - COLLAPSED_HEADER_HEIGHT*(self.depth));
viewController.view.frame = containerRect;
[self.view addSubview:viewController.view];
// viewController.view.alpha = 0;
//assume that the new view controller is positioned at the bottom of the screen
viewController.view.transform = CGAffineTransformIdentity;
// CGFloat travelDistance = self.view.bounds.size.height - COLLAPSED_HEADER_HEIGHT - NAVIGATION_BAR_HEIGHT;
CGFloat travelDistance = self.view.bounds.size.height - COLLAPSED_HEADER_HEIGHT - NAVIGATION_BAR_HEIGHT;
if(self.depth>1) {
travelDistance += NAVIGATION_BAR_HEIGHT;
}
travelDistance += NAVIGATION_BAR_HEIGHT;
if (self.depth >= 2) {
travelDistance -=NAVIGATION_BAR_HEIGHT;
}
if (self.depth == 5) {
travelDistance -=NAVIGATION_BAR_HEIGHT;
}
CGAffineTransform travel = CGAffineTransformMakeTranslation (0, -travelDistance);
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:kDamping initialSpringVelocity:kInitialSpringVelocity options:0x00 animations:^{
viewController.view.transform = travel;
viewController.view.alpha = 1;
} completion:^(BOOL finished) {
// self.view.transform = CGAffineTransformIdentity;
[viewController didMoveToParentViewController:self];
//mayanktest [self.tableView reloadData];
}];
}
는 깊이가 여기 만의 수를 결정한다 :
DRProductWriteRatingViewController *writeRatingVC = [[DRProductWriteRatingViewController alloc] initWithNibName:@"DRProductWriteRatingViewController" bundle:nil];
writeRatingVC.productDict = [productDict mutableCopy];
newVC = [[DRRatingNestedViewController alloc] initWithFrame:CGRectMake(0,0,320,[UIScreen mainScreen].applicationFrame.size.height- COLLAPSED_HEADER_HEIGHT*self.depth) andEntity:childEntity andListing:_listing];
newVC.category = self.category;
// self.depth = self.depth+1;
dispatch_async(dispatch_get_main_queue(), ^{
writeRatingVC.tableView.frame = CGRectMake(0,0,320,[UIScreen mainScreen].applicationFrame.size.height- COLLAPSED_HEADER_HEIGHT*self.depth-40);
[newVC.tableView removeFromSuperview];// removing tableview of nestedVC as it is irrelevant
[newVC addChildViewController:writeRatingVC];
[newVC.view addSubview:writeRatingVC.view];
[writeRatingVC didMoveToParentViewController:newVC];
});
이 또한 내가 먼저 하나 이상의 초 NestedViewController를 밀어 방법은 다음과 같이 간다
NestedVCs가 추가되었습니다.First Nested VC: DRRatingNestedViewController: 0xd3a9520
Second Nested VC: DRRatingNestedViewController: 0xd0b4f50
Child View to Second Nested VC : DRProductWriteRatingViewController: 0xd0c15b0
개체가 0xd3a9520 인 tableViewDelegate가 호출됩니다. 이것이 내 문제입니다.
여기에서 무엇이 문제가되어야합니까?