2017-05-14 1 views
0

NSComboBoxに必要な機能がないため、自分のcomboBoxを作成しようとしています。「メイン」のストーリーボードに影が描画されますが、他のストーリーボードには描画されません

私はNSTextFieldをサブクラス化し、textinputを監視し、stringValueに応じてTableViewはデータを取得します。

したがって、TableViewを表示する必要がある場合、TextFieldsスーパービューはNSScrollViewを追加し、その高さを調整します。 それはすべて正常に動作します。

DropShadowはうまくいきません。

したがって、main.Storyboardに新しいXcode-Projectを作成してNSTextFieldを追加し、クラスを自分のサブクラスに変更します。 テキストを入力すると、TableViewが表示され、ドロップシャドウが表示されます。

次へ新しいStoryboardを作成し、新しいWindowControllerを追加し、main.Storyboardと同じ手順を実行します。NSTextFieldを追加して、クラスを自分のサブクラスに変更します。 これで、メインストーリーボードにボタンを追加します。このボタンには、新しいストーリーボードを提示するアクションがあります。

新しいストーリーボードでは、textfieldとtableViewは、TableView/ScrollViewにシャドウがないことを除いて、期待通りに動作します。

[一般]タブのMainInterfaceを新しいストーリーボードに変更した場合でも、TableViewのDropShadowはありません。

両方のストーリーボードのIBの設定が同じに見えます。

どのように私はこれを修正することができますヒント?ここで

がscrollViewを追加して表示するためのコードです:簡単なテストの後

self.scrollView = NSScrollView(frame: NSRect.zero) 
self.scrollView!.documentView = self.tableView 
self.scrollView!.translatesAutoresizingMaskIntoConstraints = false 
self.scrollViewHeightConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 100) 
let topConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0) 
let widthConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.width, multiplier: 1, constant: 0) 
let leadinghConstraint = NSLayoutConstraint(item: self.scrollView!, attribute: NSLayoutAttribute.leading, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.leading, multiplier: 1, constant: 0) 
superview.addSubview(self.scrollView!) 
superview.addConstraints([self.scrollViewHeightConstraint!,topConstraint,widthConstraint,leadinghConstraint]) 

let dropShadow = NSShadow() 
dropShadow.shadowColor = NSColor.darkGray 
dropShadow.shadowOffset = NSMakeSize(0, 10.0) 
dropShadow.shadowBlurRadius = 3.0 

self.scrollView!.wantsLayer = true 
self.scrollView!.shadow = dropShadow 

答えて

1

...私は「問題」を発見しました。新しいViewControllersについては

は私が

self.view.wantsLayer = true 
を設定しなければならなかったビュー
関連する問題