swipe view using UISwipeGestureRecognizer
hi all freind i want ask somthing, i try use label to swipe between views but i cant know the problem?
UISwipeGestureRecognizer *swipe;
swipe = [[UISwipeGestureRec开发者_运维知识库ognizer 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];}
You could do this -
- (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];
}
You can use the same logic to swipe back from your newView
to oldView
.
Set label.userInteractionEnabled = YES
. The default value for UILabel
is NO
, therefore all touches are ignored.
userInteractionEnabled A Boolean value that determines whether user events are ignored and removed from the event queue.
@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled
Discussion This property is inherited from the UIView parent class. This class changes the default value of this property to NO.
精彩评论