相关疑难解决方法(0)

文本在UITextView框边界之外滚动

我有一个UITextView,里面有一些文字.问题是文本滚动到UITextView框的边界之外.(UITextView是不可编辑的.)

这是代码以及我试图解决此问题的方法:

  - (void)viewDidLoad {

        textBG.contentInset = UIEdgeInsetsZero;

    //  textBG.layer.masksToBounds = NO;
        textBG.layer.cornerRadius = 10.0;
        textBG.layer.borderWidth = 0.0;
        [textBG setClipsToBounds:YES];

    [super viewDidLoad];
}

- (void)textViewDidBeginEditing:(UITextView*)textView
{

textBG.contentInset = UIEdgeInsetsZero;    
 [textBG setClipsToBounds:YES];   
}

- (void) shouldChangeTextInRange:(UITextView*)textView {

    textBG.contentInset = UIEdgeInsetsZero;    
    [textBG setClipsToBounds:YES];

}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

在此输入图像描述

iphone objective-c uitextview ios

13
推荐指数
1
解决办法
3978
查看次数

替换 uitextview 的布局管理器

Mac OS X上的NSTextContainer有一个方法replaceLayoutManager:用NSLayoutManager的子类替换NSTextView的NSLayoutManager。

不幸的是iOS没有这样的功能。我尝试了这些代码行的组合,但它不断崩溃。

THLayoutManager *layoutManager = [[THLayoutManager alloc] init];
    [layoutManager addTextContainer:[self textContainer]];

    //      [[self textStorage] removeLayoutManager:[self layoutManager]];
    //[[self textStorage] addLayoutManager:layoutManager];
    [[self textContainer] setLayoutManager:layoutManager];
Run Code Online (Sandbox Code Playgroud)

替换 UITextview 的 NSLayoutManager 的正确步骤是什么?

nslayoutmanager uitextview ios7

4
推荐指数
1
解决办法
5234
查看次数

标签 统计

uitextview ×2

ios ×1

ios7 ×1

iphone ×1

nslayoutmanager ×1

objective-c ×1