0


我需要通過使用捲曲動畫進行滑動來切換視圖以進行過渡。
我試過PageControl(和其他方法-.-),但這不是我需要的幾個原因,所以我會去做手勢識別,但是我卡住了。使用捲曲動畫滑動視圖

我現在的問題是架構。有第一個VC,調用SecondVC,我在其上添加(第三個VC的)子視圖,這應該是可以滑動的。我不知道是否有可能在另一個VC的子視圖中滑動,或者如果它是代碼或IB設置不會做這項工作(這是我第一次用手勢識別)

所以現在我當第二個VC加載時剛剛加載了4個虛擬子視圖。我的GR-代碼(只是爲了leftswipe,但rightswipe或多或少相同。)

- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer { 

NSInteger viewToBeShown = 0; 
NSString *nextSubviewStr = [NSString stringWithFormat: @"view%d", (viewToBeShown)]; 

if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft){ 
    if (currentSubview >0) { 
     viewToBeShown = currentSubview-1; 
     nextSubviewStr = [NSString stringWithFormat: @"view%d", (viewToBeShown)]; 
     Ubg *nextSubview = [[Ubg alloc] initWithNibName:nextSubviewStr bundle:nil]; 
     [self.view removeFromSuperview]; 
     [self.view addSubview:nextSubview.view];  

難道你如果能告訴我應該基本工作(這只是我的IB設置,這不是正確的)?這讓我瘋狂!如果您需要任何其他信息,請告訴我。

謝謝你的時間和耐心!

+0

什麼是'這裏self'的代碼? – 2011-05-22 18:26:16

+0

nextSubview.view將永遠不會顯示,因爲它的超級視圖(self.view)將從前一行的視圖層次結構中刪除。 – omz 2011-05-22 21:39:31

回答

0

這是用於捲曲動畫

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration: 1]; 

//setting animation for the current view 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES]; 

//Next ViewController to push 
nextPage *detailViewController = [[nextPage alloc] initWithNibName:@"nextPage" bundle:nil]; 

//Push the next viewcontroller to NavigationController 
[self.navigationController pushViewController:detailViewController animated:NO]; 
[detailViewController release]; 

//Start the Animation 
[UIView commitAnimations];