0

UITextViewonを追加しようとしていUIScrollviewます。を に追加しUIScrollViewますUIView。scrollView の追加は機能しますが、 a へのUIView追加は機能しません。ポインタはありますか?UITextViewUISCrollView

ありがとう

UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(300, 400, 250, 250)];
contentScrollView.backgroundColor = [UIColor whiteColor];
UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(300, 400, 200, 200)];
mainContent.text = @"HELLO";
mainContent.textColor = [UIColor blackColor];
[contentScrollView addSubview:mainContent];
[contentScrollView setUserInteractionEnabled:YES];
[contentView addSubview:contentScrollView];
4

3 に答える 3

4

スクロール ビューの高さは 250 で、幅も 250 です。

UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
于 2012-05-28T14:52:04.400 に答える
2

このコードを使用してください:

UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 50, 320, 270)];
contentScrollView.backgroundColor = [UIColor whiteColor];
[contentScrollView setUserInteractionEnabled:YES];    

UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(60, 30, 200, 200)];
mainContent.text = @"HELLO";
mainContent.textColor = [UIColor blackColor];

[contentScrollView addSubview:mainContent];        
[self.view addSubview:contentScrollView];
于 2012-05-28T15:51:51.107 に答える
1

このテクニックを使う

UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 50, 320, 270)];

そしてそれをあなたのようなものに追加してくださいUIScrollView

UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
contentScrollView.backgroundColor = [UIColor whiteColor];
[contentScrollView setUserInteractionEnabled:YES];    
[contentScrollView addSubview:mainContent];        
于 2014-12-31T09:08:06.920 に答える