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

发布于 2024-09-01 14:48:40 字数 855 浏览 2 评论 0原文

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

   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 ));  

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

谢谢。

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 ?

Thank You.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

維他命╮ 2024-09-08 14:48:40

我不知道这是否是一个好的解决方案。但这对我有用。我在这里发帖,以便任何人都可以纠正它。

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

这对我有用。它仅上下滚动,也上下弹跳。

谢谢。

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.

Thank You.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文