本文介绍了如何以编程方式停止水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在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.
谢谢。
更多推荐
如何以编程方式停止水平滚动?
发布评论