私はUIView型のself.photoViewを持っていますが、私はUIImageViewであるphotoImageViewを持っています。私はself.photoViewの中にphotoImageView XとYを配置したいと思います。Autolayout制約を使用して親ビュー内のビューを中央揃え
このコードは何も実行していません!
let photoImageView = UIImageView.imageViewForPhotoTaken(self.photoView.bounds, image: img)
photoImageView.contentMode = UIViewContentMode.ScaleAspectFit
self.photoView.addSubview(photoImageView)
// set the autolayout constraints
self.photoView.addConstraint(NSLayoutConstraint(item: self.photoView, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: photoImageView, attribute: NSLayoutAttribute.CenterX, multiplier: 1.0, constant: 0))
後に呼び出される任意の方法があり、私は、サブVIを整列しますew(photoImageView)の中心は水平と垂直です。 –
両方の軸の制約を作成する必要があります。さらに、高さと幅の制約を宣言する必要があります。コードでは、UIImageViewのサイズが0以外のサイズであることが示されています – Loxx
問題は解決しましたか? ? – HardikDG