大家好朋友,我想问问题,我尝试使用标签在视图之间滑动,但我不知道问题?
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];}
答案 0 :(得分: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
向oldView
向后滑动。
答案 1 :(得分:0)
设置label.userInteractionEnabled = YES
。 UILabel
的默认值为NO
,因此会忽略所有触摸。
userInteractionEnabled用于确定是否为用户的布尔值 事件被忽略并从事件队列中删除。
@property(nonatomic,getter = isUserInteractionEnabled)BOOL userInteractionEnabled
讨论此属性继承自 UIView父类。此类更改此默认值 财产到NO。