2011-11-21 95 views
1

以下代碼片段顯示在正確的背景上,但文本不滾動。UITextView不滾動,需要幫助

我在想什麼?

-(void) viewWillAppear:(BOOL)animated { 

    UITextView *scrollableText = [[UITextView alloc] initWithFrame:CGRectMake(20, 20, 300, 800)]; 
    [scrollableText setOpaque:TRUE]; 
    [scrollableText setBackgroundColor:[UIColor clearColor]]; 

    [scrollableText setEditable:NO]; 
    [scrollableText setText:@"some really really long text"]; 

    [scrollableText setScrollEnabled:YES]; 

    UIImage *backgroundImage = [[UIImage alloc] initWithCGImage:[UIImage imageNamed:@"about_bg.png"].CGImage]; 
    UIImageView *backgroundView = [[UIImageView alloc] initWithImage:backgroundImage]; 

    [backgroundView addSubview:scrollableText]; 

    [[self view] addSubview:backgroundView]; 
} 

回答

3

除了setScrollEnabled嘗試[textview setUserInteractionEnabled:YES]textView.userInteractionEnabled = YES;

+2

不幸的是,這是行不通 – JAM

1

我有同樣的問題,我在這種模式下解決。 在您的視圖中放入像OBGradientView這樣的自定義視圖,並在此添加您的textView。在代碼中添加 以查看您的ObGradientView並添加textview。 工作100%信任我

這裏的鏈接,subview