2012-03-10 24 views
0

创建UITextViewUIScrollViewUITtextView在UIScrollView中

scrollView = [[UIScrollView alloc]init]; 

self.textView = [[[UITextView alloc] initWithFrame:CGRectMake(10, 225, 300, 100)]autorelease]; 

self.textView.textColor = [UIColor brownColor]; 

self.textView.font = [UIFont fontWithName:@"Georgia-Bold" size:14]; 

self.textView.textAlignment = UITextAlignmentCenter; 

self.textView.backgroundColor = [UIColor colorWithHue:2.0/12 saturation:2.0 brightness:4.0/10 alpha:1.0]; 

self.textView.editable = NO; 

self.textView.textAlignment = UITextAlignmentCenter; 

self.textView.text = @"this is uitext. this is uitext....."; 

[scrollView addSubview:textView]; 

所有读音字能看到的是黑屏,为什么我不是看到我的TextView。

感谢您的帮助。

+0

你在哪里推,显示或添加scrollView本身? 我重新这是在你的一个视图控制器。因此您首先必须将scrollview剪辑到您的视图(作为子视图或推送视图)。这应该可以解决它。 – 2012-03-10 22:50:38

+0

或在您的界面中创建scrollView并将其与出口连接到您的viewcontroller =) – 2012-03-10 22:52:39

+0

我不使用interfacebuilder,但编程 – user1120133 2012-03-10 22:53:52

回答

2

尝试这个代码

[self.scrollView addSubview:textView]; 

希望这有助于你

+0

我尝试过,但仍然输出 – user1120133 2012-03-10 22:35:31

0

可能解决个月前,但这也许应该这样做(的人,谷歌和发现这个问题)

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 
[self.view addSubview:scrollView]; 
0
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 
[self.view addSubview:scrollView]; 
self.textView = [[[UITextView alloc] initWithFrame:CGRectMake(10, 225, 300, 100)]autorelease]; 

self.textView.textColor = [UIColor brownColor]; 

self.textView.font = [UIFont fontWithName:@"Georgia-Bold" size:14]; 

self.textView.textAlignment = UITextAlignmentCenter; 

self.textView.backgroundColor = [UIColor colorWithHue:2.0/12 saturation:2.0 brightness:4.0/10 alpha:1.0]; 

self.textView.editable = NO; 

self.textView.textAlignment = UITextAlignmentCenter; 

self.textView.text = @"this is uitext. this is uitext....."; 

[scrollView addSubview:textView];