如何以编程方式创建UITextView时启用滚动

rkb*_*rkb 2 iphone

我以编程方式创建了一个UITextView,并希望为该UITextView启用滚动.

是否有任何属性或方法可以做到这一点becoz默认情况下不启用它.我使用以下代码显示它但不向下滚动.

UITextView* txt_tipView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 165, 60)];
        txt_tipView.backgroundColor = [UIColor clearColor];
        txt_tipView.textColor = [UIColor colorWithRed:(51/255) green:(51/255) blue:(51/255) alpha:1];

        txt_tipView.font = [UIFont fontWithName:@"Helvetica" size:12];//[UIFont boldSystemFontOfSize:12];
        txt_tipView.editable = FALSE;

        txt_tipView.frame = CGRectMake(138, 96, 165, 60);
        [self.view addSubview:txt_tipView];
Run Code Online (Sandbox Code Playgroud)

pix*_*x0r 5

UITextView继承自UIScrollView(您可以在Interface Builder的Inspector选项卡中或通过文档查看).这意味着UIScrollView的任何属性也可以在UITextView上设置:

txt_tipView.scrollEnabled = YES;
Run Code Online (Sandbox Code Playgroud)