2014-04-03 53 views

回答

2

什么最有可能是在这种情况下被遗忘的是添加以下代码加载笔尖并将其添加到自定义视图的/控件的子视图的背景:

UIView* rootView = [[[NSBundle mainBundle] 
        loadNibNamed:className owner:self options:nil] firstObject]; 
rootView.translatesAutoresizingMaskIntoConstraints = NO; 

[self addConstraint: 
[NSLayoutConstraint 
    constraintWithItem:rootView attribute:NSLayoutAttributeTop 
    relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop 
    multiplier:1.0f constant:0.0f]]; 

// And so on for all attributes (Bottom, Left, Right) that you want to 
// constrain the loaded nib with. 

(其中自是自定义的UIView/Widget实例。)

相关问题