V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
lcl22hope
V2EX  ›  iDev

利用 NSTextStorage\NSTextLayout\NSTextContainer 初始化 UITextView 时 textview 不能滚动问题

  •  
  •   lcl22hope · 2015-04-14 17:21:38 +08:00 · 2936 次点击
    这是一个创建于 3543 天前的主题,其中的信息可能已经有所发展或是发生改变。
    scrollEnabled 已经 Yes,超出部分无法滚动查看,是我哪里用错了么?求教
    参考这篇文章,实现的缩进 http://www.ituring.com.cn/tupubarticle/2542
    CGRect textViewRect = CGRectInset(_layerView.bounds, 5, 5);
    _textStorage = [[NSTextStorage alloc] initWithString:text];
    NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
    [_textStorage addLayoutManager:layoutManager];
    _textContainer = [[NSTextContainer alloc] initWithSize:textViewRect.size];
    [layoutManager addTextContainer:_textContainer];
    [_contentEditView removeFromSuperview];
    _contentEditView = [[UITextView alloc] initWithFrame:textViewRect textContainer:_textContainer];
    _contentEditView.backgroundColor = [UIColor purpleColor];
    _contentEditView.layer.cornerRadius = 5;
    _contentEditView.layer.masksToBounds = YES;
    _contentEditView.font = HIRAGINO_SANSGB_W3_FONT;
    [_contentEditView setShowsHorizontalScrollIndicator:NO];
    _contentEditView.delegate = self;
    [_layerView addSubview:_contentEditView];
    1 条回复    2015-04-14 23:46:21 +08:00
    Galvin
        1
    Galvin  
       2015-04-14 23:46:21 +08:00
    textview的contentsize 输出一下看看?也许某些地方没有让textview内容自适应?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3475 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 04:53 · PVG 12:53 · LAX 20:53 · JFK 23:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.