2013-07-21 4 views
0

방금 ​​TabView를 실행할 수 있도록 앱의 섹션이 너무 많아서 내 앱이 CollectionView로 구동되는 TabView가 아닌 ​​것으로 변경되었습니다. 응용 프로그램을 시작하면 CollectionView에 여러 항목이 표시되고 항목 중 하나를 선택하면 응용 프로그램의 관련 섹션으로 이동합니다.UIViewControllers 간의 사용자 지정 전환

XCode에서 컬렉션보기는 자체 스토리 보드에 있으며 앱의 각 섹션에는 자체 스토리 보드가 있습니다.

CollectionView의 didSelectItemAtIndexPath에서 다음과 같이 관련 우현을 실행합니다. 이제

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"relevant_storyboard" bundle:nil]; 
UIViewController* vc = [storyboard instantiateInitialViewController]; 
[self presentViewController:vc animated:YES completion:nil]; 

, 정말 소송하는 CollectionView에서 시작 내장 전환 애니메이션 중 어느 것도 그래서 나는 정말 같은 확대하면 사용자 정의 효과처럼. 그러나, 나는 어떤 점잖은 예를 찾기 위해 고군분투없는거야 것 어떤 종류의 커스텀 트랜지션을 만들 수있는 작품. [UIView transitionFromView] 시도했지만 UIViewControllers 사이의 전환 양복 생각하지 않습니다. transitionFromViewController:toViewController:을 시도했지만 올바르게 뷰 계층을 설정했다고 생각하지 않습니다. 또한 성공없이 CATransition을 사용해 보았습니다.

커스텀 세그 (Segue)를 사용하여 생각하고 있지만 내 CollectionView는 자체 스토리 보드이며 내 앱의 각 섹션마다 별도의 스토리 보드가 있으므로 어떻게 할 수 있는지 알 수 없습니다. 적어도 하나의 스토리 보드 안에 앱의 모든 섹션이 없어도 스토리 보드를 거대하고 관리하기 어려울 것입니다.

그래서, 아무도 내가 이것을 해결할 수있는 방법에 대한 모든 코드 예제 또는 포인터를 제공 할 수 있습니까?

+0

나는 이것이 UIViewController 포함을 실제로 이해하지 못하기 때문에 이것으로 고민하는 이유가 있다고 생각합니다. 나는 그걸 먼저 읽어야 할 것 같아.나는 또한 이것을 설명하는 WWDC 2011 세션 102 비디오를 보려고하는데, 해킹으로 인해 목요일 이후로 dev 사이트가 다운되었습니다. 다운로드 한 모든 WWDC 비디오 중에서 그 중 하나가 아닙니다. 한숨. – swampf0etus

답변

1

UIView 애니메이션 블록을 사용해 보셨습니까?

[UIView animationWithDuration:1.0 animation^ { 
    // do custom animation with the view 
}completion:^(BOOL finished) { 
    if(finished) { 
     NSLog(@"Finished"); 
    } 
}]; 

UIView를 처리 할 때 및 UIViewController를 사용하는 경우에도 사용자 지정 애니메이션을 수행 할 수 있습니다. 나는 커스텀 애니메이션 액션을 다룰 때 많이 사용한다.

편집 : 당신이 그것을 대신에 아래로 슬라이드 화면, 두 번째 뷰 컨트롤러를 이동하는 전류 제어기의 전망을하려는 경우

예를 들어, 단지 할

[UIView animationWithDuration:1.0 animation^ { 
    // do custom animation with the view 
    // make sure CoreGraphics.framework is imported 
    // sliding current view to the top of the screen 
    self.view.transform = CGAffineTransformMakeTranslation(0,0); 

    // sliding 2nd view down.. 
    // uncomment the following line, and one of the options for translation 
    //SecondView *sv = [[SecondView alloc] init]; 
    // just edit the x,y in CGAffineTransformMakeTranslation to set where it will go 
    //sv.view.transform = CGAffineTransformMakeTranslation(320, 480) // iphone 4 
    //sv.view.transform = CGAffineTransformMakeTranslation(768, 1024) // ipad 1 

}completion:^(BOOL finished) { 
    if(finished) { 
     NSLog(@"Finished"); 
    } 
}]; 

희망이 도움이됩니다.

1

내 응용 프로그램에서는 비슷한 효과를 사용하여 컬렉션보기 셀의 축소판에서 전체 화면을 차지하는 하위보기 컨트롤러로 확대했습니다. 네비게이션 컨트롤러 푸시에 대해서도 똑같은 일을 할 수 있습니다.

내 코드에는 셀 서브 클래스에 scoreView 속성이있어 전체 화면을 확대하고 싶습니다. 귀하의 경우 새로운보기의 스크린 샷과 함께 UIImageView을 사용할 수 있습니다. 또는 새 뷰 컨트롤러에 이전 뷰 컨트롤러의 스크린 샷을 표시 한 다음 거기에서 애니메이션을 적용 할 수 있습니다.

//Instantiate the view controller to be animated in... 

//If the cell is not completely inside the collection view's frame, a dissolve animation might be more graceful. 
BOOL dissolveAnimation = !CGRectContainsRect(CGRectMake(0, 0, self.collectionView.frame.size.width, self.collectionView.frame.size.height), cellRect); 

//Get the frame of the cell in self.view coordinates, then the frame of the thumbnail view 
CGRect cellRect = [self.collectionView layoutAttributesForItemAtIndexPath:indexPath].frame; 
cellRect = CGRectOffset(cellRect, 0.0, -self.collectionView.contentOffset.y); 
VSScoreCell *scoreCell = (VSScoreCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; 
CGRect scoreRect = dissolveAnimation ? CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height) : CGRectMake(cellRect.origin.x + scoreCell.scoreView.frame.origin.x, cellRect.origin.y + scoreCell.scoreView.frame.origin.y, scoreCell.scoreView.frame.size.width, scoreCell.scoreView.frame.size.height); 
VSScoreView *scoreView = [[VSScoreView alloc] initWithFrame:scoreRect]; 

//Initialize the view that will be animated up (in this case scoreView)... 

if (dissolveAnimation) 
    scoreView.alpha = 0.0; 

[self.view addSubview:scoreView]; 

[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ 
    if (dissolveAnimation) 
     scoreView.alpha = 1.0; 
    else 
     scoreView.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height); 
} completion:^(BOOL finished) { 
    if (finished) 
    { 
     //Add scoreDisplayController as a child view controller or present it without animation 
     [scoreView removeFromSuperview];    
    } 
}]; 

은 물론, 새로운 아이폰 OS는 (내 입술은 밀봉)이 쉽게 만들 수도 있지만, 나는이 상황에 다소 도움이 희망!

+0

이 답변은 내 앱이 현재 작동하는 방식, 즉 내 질문에서 설명했던 방식에 가장 적합하다고 생각합니다. 나는 이것을 시도 할 것이지만,이 모든 질문은 내 앱이 어떻게 작동하는지 생각하게 만들었고 나는 그것을 바꿀 것이라고 생각한다. 그래도 여전히 전환 애니메이션을 사용하게 될 것이므로 여전히 관련성이 있습니다. – swampf0etus