TableViewをつかってグラフを表示するアプリを作っています。
データはJSONで取得しており、取得結果は50でした。
50/100=0.5という値を制約に追加して対応しました。
シュミレーションで上下に動かしたら、下記のメッセージが表示されました。
ちなみに、メッセージは縦向きではでません。(横向きの時だけでます)
さらに、JSONで取得した50ではなく、手入力で「50」としたら、
問題なく動作します。(デバッグメッセージはでません)
どなたか、お知恵をお貸し願えませんでしょうか?
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x7fd7ebd5b8b0 UIView:0x7fd7ebd597e0.width == 0.5UITableViewCellContentView:0x7fd7ebd59650.width>",
"<NSLayoutConstraint:0x7fd7ebd5bb60 H:|-(0)-[UIView:0x7fd7ebd597e0] (Names: '|':UITableViewCellContentView:0x7fd7ebd59650 )>",
"<NSLayoutConstraint:0x7fd7ebd5bbb0 H:[UIView:0x7fd7ebd5a300]-(5)-| (Names: '|':UITableViewCellContentView:0x7fd7ebd59650 )>",
"<NSLayoutConstraint:0x7fd7ebd5bd40 H:[UIView:0x7fd7ebd597e0]-(0)-[UIView:0x7fd7ebd5a300]>",
"<NSLayoutConstraint:0x7fd7ebe96450 UILabel:0x7fd7ebd5a490'7'.width == 0.4UIView:0x7fd7ebd5a300.width>",
"<NSLayoutConstraint:0x7fd7ebd21010 UILabel:0x7fd7ebd5a490'7'.width == 0.07*UIView:0x7fd7ebd5a300.width>",
"<NSLayoutConstraint:0x7fd7ebffbfd0 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x7fd7ebd59650(736)]>"
)
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
下記が、UITableViewCellに割り当てているクラスです。
class TableViewCell: UITableViewCell {
//セル幅
@IBOutlet weak var rightView: UIView!
//比率を表す棒グラフ
@IBOutlet weak var graphLabel: UILabel!
// セル内セット(50がきます) func configureCell(qty: Int){ let multiplier = CGFloat(qty) / CGFloat(100) rightView.addConstraint( NSLayoutConstraint( item: self.graphLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: self.rightView, attribute: NSLayoutAttribute.Width, multiplier: multiplier, constant: 0 ) ) }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/10/28 01:22
2015/10/28 03:09 編集
2015/10/28 04:01