Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa touch 如何以编程方式停止水平滚动?_Cocoa Touch_Uitextview_Cocos2d Iphone - Fatal编程技术网

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

Cocoa touch 如何以编程方式停止水平滚动?,cocoa-touch,uitextview,cocos2d-iphone,Cocoa Touch,Uitextview,Cocos2d Iphone,我在cocos2d的CCLayer中有一个UITextView*textView。文本在水平和垂直方向上滚动。但是,我需要它只在垂直方向滚动和反弹。 如何以编程方式停止水平滚动 UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(100,200, windowSize.height/2,windowSize.width/2)]; textView.backgroundColor = [UIColor c

我在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 ));  
如何停止水平滚动


谢谢。

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

    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];   
这对我有用。它只会上下滚动,也会上下反弹


谢谢。

所以您只硬编码较小的字体?我想您可以计算textView的contentView边界并调整字体大小,使其适合textView