UITextView just horizontal scrolling help

后端 未结 4 1107
遇见更好的自我
遇见更好的自我 2021-01-14 08:13

I have a UITextView , i want show its\' text in horizontal, my UITextView has a static width

[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 161, 23)];
<         


        
相关标签:
4条回答
  • 2021-01-14 08:45

    put this code after initializing

    [txt setContentOffset:CGPointMake(give_high_value_here_than_content, y)];
    

    Good luck

    0 讨论(0)
  • 2021-01-14 08:46

    mscrollview.contentSize = CGSizeMake(180,30);
    mscrollview.showsHorizontalScrollIndicator = YES;

    Use this 2 lines.

    0 讨论(0)
  • 2021-01-14 08:59
    - (void)viewDidLoad {
        // We restrict the horizontal scrolling here.
        self.textView.contentSize = self.textView.frame.size;
    }
    

    Implement this text view delegate method.

    Now when the characters entered becomes greater than 23, we set the content size of the text view to a higher value so that horizontal scrolling gets enabled automatically.

    - (void) textViewDidChange:(UITextView *) tView {
        if (tView.text.length > 23) {
    // Set some higher width of the text view content size.
            tView.contentSize = CGSizeMake(200.0f, tView.frame.size.height);
        }
    }
    
    0 讨论(0)
  • 2021-01-14 09:03

    If you are using interface builder then just check the property.

    show horizontal scrolling.
    

    by default this property is not enable

    0 讨论(0)
提交回复
热议问题