iphone - 使用 UISwipeGestureRecognizer 滑动 View

标签 iphone ios objective-c uigesturerecognizer uiswipegesturerecognizer

嗨所有 friend 我想问点事,我尝试使用标签在 View 之间滑动但我不知道问题是什么?

UISwipeGestureRecognizer *swipe;
swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(Gest_SwipedLeft:)];
[swipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[label addGestureRecognizer:swipe];
[swipe release];


-(void)Gest_SwipedLeft:(UISwipeGestureRecognizer *) sender{
      ThirdQPage* y=[[ThirdQPage alloc]init];
[self.view.superview addSubview:[y view]];
[self.view removeFromSuperview];}

最佳答案

你可以这样做 -

- (void)hideView:(NSTimer *)timer
{    
    UIView *currentView = (UIView *)[timer userInfo];
    [currentView addSubview:self.yourNewView];
    return;
}

-(void)Gest_SwipedLeft:(UISwipeGestureRecognizer *) sender
{
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                           forView:yourCurrentView cache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1];
    [NSTimer scheduledTimerWithTimeInterval:0.5 
                                     target:self 
                                   selector:@selector(hideView:) 
                                   userInfo:yourCurrentView 
                                    repeats:NO];
    [UIView commitAnimations];
}

您可以使用相同的逻辑从 newView 滑动回 oldView

关于iphone - 使用 UISwipeGestureRecognizer 滑动 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6982720/

相关文章:

ios - Cordova App -> iOS 存档验证失败。图标不见了

iOS Facebook SDK 3.0 登录不重定向到原始应用程序

ios - dispatch_async超时方法调用

iphone - Cocos2dx iOS App 崩溃

iphone - Objective-C - 如何获取数组中对象的索引

ios - UIPanGestureRecognizer 有时不会进入最终状态

ios - 在 iOS 上检测飞行模式

iphone - 可执行文件使用无效的权利进行签名

iphone - 制作我自己的瓷砖系统导致滞后

ios - UITextView 调用上一个号码