使用curl动画滑动视图

时间:2011-05-22 18:19:04

标签: iphone objective-c interface-builder gesture-recognition


我需要通过使用卷曲动画进行切换来切换视图以进行转换。
我尝试了PageControl(以及其他方法-.-),但由于几个原因,它不是我需要的,所以我会选择GestureRecogntion,但我卡住了。

我现在的问题是架构。有第一个VC,调用SecondVC,我将(第三个VC)的子视图添加到其中,应该是可刷卡的。我不知道是否有可能从另一个VC中刷过子视图,或者它是不能完成工作的代码或IB设置(这是我第一次使用手势识别)

所以到现在为止,当加载第二个VC时,我只加载了4个虚拟子视图。我的GR代码(仅适用于leftswipe,但版权所有或多或少相同......)

- (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设置不正确)?这让我疯了!如果您需要任何其他信息,请告诉我。

感谢您的时间和耐心!

1 个答案:

答案 0 :(得分: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];