开发者

How to stop the horizontal scrolling programmatically?

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.t开发者_Python百科ext = @"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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜