我编写了一个代码,用于将文本包含在视图中
-(void)buildFrames
{
NSTextStorage *textstorege=[[NSTextStorage alloc]initWithAttributedString:self.bookMarkup];
_layoutManager =[[NSLayoutManager alloc]init];
[textstorege addLayoutManager:_layoutManager];
NSTextContainer *textcontainer=[[NSTextContainer alloc]initWithSize:CGSizeMake(self.bounds.size.width, FLT_MAX)];
[_layoutManager addTextContainer:textcontainer];
UITextView *textView = [[UITextView alloc]initWithFrame:self.bounds textContainer:textcontainer];
textView.scrollEnabled = YES;
[self addSubview:textView];
}
然后错误就像财产" Bounds"在对象类型视图控制器中找不到...
答案 0 :(得分:2)
你的专栏:
UITextView *textView = [[UITextView alloc]initWithFrame:self.bounds textContainer:textcontainer];
如果self
是UIViewController
或UISplitViewController
,那么self
没有界限,它就是控制器。您想要控制器负责的视图的界限。
尝试self.view.bounds
,这样你的行就会变成:
UITextView *textView = [[UITextView alloc]initWithFrame:self.view.bounds textContainer:textcontainer];