簡體   English   中英

centerXAnchor僅在iOS 9.0或更高版本中可用?

[英]centerXAnchor is only available in iOS 9.0 or newer?

所以我試圖以編程方式添加約束:
我只是添加了兩個約束,Xcode開始向我展示:

centerXAnchor僅在iOS 9.0或更高版本中可用

這是我的代碼:

var constraints = [NSLayoutConstraint]()

let centerImageX = imageView.centerXAnchor.constraint(equalTo: footerView.centerXAnchor)

let centerImageY = imageView.centerYAnchor.constraint(equalTo: footerView.centerYAnchor)

constraints = [centerImageX,centerImageY]

NSLayoutConstraint.activate(constraints)

我想分享的一件事可能令人難以置信,幾天前我還沒有收到任何錯誤消息。

我的Xcode版本是8.2.1

另外,我的部署目標是8.0及更高版本。 因此,如果有人可以告訴我,或者可以為iOS 8.0轉換或翻譯相同的代碼,那就太好了!

這應該做相同的工作:

self.view.addConstraint(NSLayoutConstraint(item: imageView, attribute: .centerX, relatedBy: .equal, toItem: footerView, attribute: .centerX, multiplier: 1.0, constant: 0))
self.view.addConstraint(NSLayoutConstraint(item: imageView, attribute: .centerY, relatedBy: .equal, toItem: footerView, attribute: .centerY, multiplier: 1.0, constant: 0))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM