2012-03-10 58 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];