2014-04-03 84 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實例。)

相關問題