0

大家好,我想问一下,我尝试使用标签在视图之间滑动,但我不知道问题所在?

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];}
4

2 回答 2

3

你可以这样做——

- (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您可以使用相同的逻辑从您的to向后滑动oldView

于 2011-08-08T13:45:04.727 回答
0

设置label.userInteractionEnabled = YES。的默认值为UILabelNO因此所有触摸都被忽略。

userInteractionEnabled 一个布尔值,用于确定是否忽略用户事件并将其从事件队列中删除。

@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled

讨论 该属性继承自 UIView 父类。此类将此属性的默认值更改为 NO。

于 2011-08-08T13:52:08.530 回答