2010-05-10 86 views
2

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

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

谢谢。

回答

1

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

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

它为我工作。它只能上下滚动,也会上下跳动。

谢谢。

+0

所以你只硬编码较小的字体大小?我猜你可能已经计算了textView的contentView边界并调整了字体大小,以便它适合textView – kervich 2013-04-02 12:15:51