現在custom Viewを作っていて、
・ CustomView.swift
・ CustomView.xib
でxibファイルでたくさんsubViewをおいて関連付けしています。
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
comminInit()
}
private func comminInit() { let bundle = NSBundle(forClass: self.dynamicType) let nib = UINib(nibName: "Custom", bundle: bundle) let view = nib.instantiateWithOwner(self, options: nil).first as! ImagePostView view.translatesAutoresizingMaskIntoConstraints = true addSubview(view) let bindings = ["view": view] addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)) }
そのCustomViewをCustoomViewControllerで、
loadViewメソッド内に
let cView = CustomView()
self.view = cView
でViewを置き換えています。
ですが、CustomViewにおいている部品が表示されません。どうすればいいでしょうか?
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/07 03:36
2016/07/07 11:34