在类型视图控制器中找不到属性“bounds”

时间:2014-09-27 07:53:27

标签: objective-c uisplitviewcontroller

我编写了一个代码,用于将文本包含在视图中

-(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"在对象类型视图控制器中找不到...

1 个答案:

答案 0 :(得分:2)

你的专栏:

UITextView *textView = [[UITextView alloc]initWithFrame:self.bounds textContainer:textcontainer];

如果selfUIViewControllerUISplitViewController,那么self没有界限,它就是控制器。您想要控制器负责的视图界限

尝试self.view.bounds,这样你的行就会变成:

UITextView *textView = [[UITextView alloc]initWithFrame:self.view.bounds textContainer:textcontainer];