2016-04-19 10 views
0

が更新されていない私は、iOS 7用AutoLayoutを使用してテーブルビューを作成しています - iOSの9のUITableViewCell +自動レイアウト、コンテンツのサイズが

私は.xibインタフェースビルダで、単一セルのプロトタイプを作成しました。セルの実装インサイド

enter image description here

私はまだ実装していません。 AutoLayout制約が正しく提供されているようだ、私はこのようなエラーが取得していたという事実にもかかわらず

、ブレークポイントに到達すると

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:0x7fad5a80c3b0 UILabel:0x7fad585a6c60.width == UILabel:0x7fad5ad9f2b0.width>", 
    "<NSLayoutConstraint:0x7fad5a84c0a0 UILabel:0x7fad5ad9f2b0.leading == UILabel:0x7fad585a6c60.trailing + 10>", 
    "<NSLayoutConstraint:0x7fad5862a140 UILabel:0x7fad585a6c60.leading == MyCustomTableViewCell:0x7fad5ad88560.leading + 10>", 
    "<NSLayoutConstraint:0x7fad58621c30 MyCustomTableViewCell:0x7fad5ad88560.trailing == UILabel:0x7fad5ad9f2b0.trailing + 10>", 
    "<NSLayoutConstraint:0x7fad5ae218c0 MyCustomTableViewCell:0x7fad5ad88560.width == 1>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fad5a84c0a0 UILabel:0x7fad5ad9f2b0.leading == UILabel:0x7fad585a6c60.trailing + 10> 

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 

を、ライン[[[0x7fad5ad9f2b0 superview] superview] recursiveDescription]表示されます。

<VideoAnalysisVideoInformationTableViewCell: 0x7fad5ad88560; baseClass = UITableViewCell; frame = (0 301; 1 35); autoresize = W; layer = <CALayer: 0x7fad585445a0>> 
    | <UITableViewCellContentView: 0x7fad585d9d60; frame = (0 0; 1 35); opaque = NO; gestureRecognizers = <NSArray: 0x7fad585a2d30>; layer = <CALayer: 0x7fad585e9b40>> 
    | | <UILabel: 0x7fad585a6c60; frame = (10 5; 145 25); text = 'Score'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer =  <_UILabelLayer: 0x7fad5850b030>> 
    | | <UILabel: 0x7fad5ad9f2b0; frame = (165 5; 145 25); text = '33'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fad5ad98210>> 
    | <_UITableViewCellSeparatorView: 0x7fad5a8cf620; frame = (15 34; 305 1); layer = <CALayer: 0x7fad5a9121d0>> 

それはそうですコンテンツビューのサイズが正しくないことを確認します。それがどうして起こるの?どうすればこの問題を解決できますか?

+0

AutoLayoutを使用するときにフレームサイズを設定しないでください。 View ControllerのheightForCellAtIndexPathメソッドでセルサイズを設定する必要があります。 –

+0

それも私の最初の考えでした。メソッドの中で、 'heightForCellAtIndexPath'セルのフレームは正しいです。 'UIViewAlertForUnsatisfiableConstraints'ブレークポイントではありません。 –

答えて

0

不適切な制約が設定されています。

は、このような制約を付け、

タイトルラベル - 大手とトップ

情報ラベル - 末尾のトップ

との両方のラベルを選択して、等しい幅を与えます。これが役立つことを願っています:)

更新:

は、リード、トップを与える末尾の両方のラベルに、高さを固定します。 と等しい幅を指定する

+0

垂直ハギングのためにこれは機能しません。また、水平方向の間隔は何にも影響しません。セルとコンテンツビューの幅が1ピクセルに過ぎない理由をご存知ですか? –

+0

デフォルトで1 pxにする必要はありません...! – Lion

+0

'AutoLayout'制約とログ構造をデバッグするためのシンボリックブレークポイント' UIViewAlertForUnsatisfiableConstraints'を追加しました(上記の質問を読んでください)。幅 - 1ピクセルを示します。 –

関連する問題