使用 UISwipeGestureRecognizer 滑动视图
大家好,我想问一些事情,我尝试使用标签在视图之间滑动,但我不知道问题所在?
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];}
hi all freind i want ask somthing, i try use label to swipe between views but i cant know the problem?
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];}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样做 -
您可以使用相同的逻辑从
newView
滑回oldView
。You could do this -
You can use the same logic to swipe back from your
newView
tooldView
.设置
label.userInteractionEnabled = YES
。UILabel
的默认值为NO
,因此所有触摸都会被忽略。Set
label.userInteractionEnabled = YES
. The default value forUILabel
isNO
, therefore all touches are ignored.