如何以编程方式停止水平滚动?

编程入门 行业动态 更新时间:2024-10-28 14:31:46
本文介绍了如何以编程方式停止水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在cocos2d的CCLayer中有一个UITextView * textView。文本在水平和垂直方向上都滚动。但是,我需要它滚动和反弹只在垂直。 如何以编程方式停止水平滚动?

I have a UITextView *textView in cocos2d's CCLayer. The text is scrolling in both the horizontal and vertical directions. But, I need it to scroll and bounce only in vertically. How to stop the horizontal scrolling programmatically ?

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(100,200, windowSize.height/2,windowSize.width/2)]; textView.backgroundColor = [UIColor clearColor]; textView.text = @"I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy I am First enemy"; [textView setEditable:NO]; textView.font = [UIFont fontWithName:@"Helvetica" size:24.0f]; CGPoint location = CGPointMake(200, 160); textView.showsHorizontalScrollIndicator = NO; //textView.bounces = NO; //textView.alwaysBounceVertical = YES; textView.center = location; textView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS( 90.0f ));

我应该怎么做才能停止水平滚动?

What should I do stop scrolling horizontally ?

谢谢。

推荐答案

我不知道这是不是好的解决方案。但它为我工作。我在这里张贴,以便任何人可以纠正它。

I don't know whether it was the good solution. But it worked for me. I am posting here so that any one may correct it.

textView = [[UITextView alloc] initWithFrame:CGRectMake(100,200,200 ,200)]; textView.backgroundColor = [UIColor clearColor]; NSLog(@"description: %@", enemyDescription); textView.text = enemyDescription; [textView setEditable:NO]; textView.font = [UIFont fontWithName:@"Helvetica" size:14.0f]; CGPoint location = CGPointMake(200, 160); textView.showsHorizontalScrollIndicator = NO; textView.alwaysBounceVertical = YES; textView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS( 90.0f )); [[[CCDirector sharedDirector]openGLView]addSubview:textView];

它适用于我。它只向上和向下滚动,也上下弹回。

It worked for me. It scrolls only up and down and also bounces up and down.

谢谢。

更多推荐

如何以编程方式停止水平滚动?

本文发布于:2023-11-03 13:37:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555254.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:水平   方式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!