[問題] table view cell 動態高度與元件
我有一個 table view 客製化了 cell
cell 內有三個UI元件,如下
┌──────────┐
│(1) 動態圖片高度 │
│ │
│(2) 動態文字高度 │
│ │
│(3) 固定文字高度 │
└──────────┘
其中 (2) 還有可能是沒有的...orz
當三個都存在的時候,我用這一篇可以做到 (但是(2)是寫死高度的...orz)
http://blog.changyy.org/2012/08/ios-interface-builder-uitableviewcell.html
我不知道要如何在(2)可能會有多行文字或者沒有文字的情況下
算出cell 的高度
並使cell 的layout不會跑掉QQ
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.21.125.247
推
01/13 13:09, , 1F
01/13 13:09, 1F
→
01/13 13:34, , 2F
01/13 13:34, 2F
→
01/13 13:35, , 3F
01/13 13:35, 3F
→
01/13 13:36, , 4F
01/13 13:36, 4F
推
01/13 13:51, , 5F
01/13 13:51, 5F
→
01/13 14:05, , 6F
01/13 14:05, 6F
我後來在 cell 裡的 layoutSubviews 給覆寫
-(void) layoutSubviews{
self.動態文字.frame = CGRectMake(x,x,x,x);
}
結果也沒反應@@|||
※ 編輯: issuemylove 來自: 211.21.125.247 (01/13 16:07)
→
01/13 17:29, , 7F
01/13 17:29, 7F
→
01/13 17:30, , 8F
01/13 17:30, 8F
→
01/13 17:30, , 9F
01/13 17:30, 9F
這個我知道@@ 主要是因為它有兩個變動長度
height我是算得出來
但我不知道要怎樣做設定 (依序畫出動態圖片、動態文字)
我最剛開始用 xib 但aotolayout我不知道要怎樣設定 弄不好orz
※ 編輯: issuemylove 來自: 211.21.125.247 (01/13 17:51)
後來我發現光是 image就很難把它固定位置
┌─────────┐
│┌───────┐│
││ 圖片高度動態 ││
│└───────┘│
│ │
...
└─────────┘
我主要是設定了 (a) pin -> Leading space to superview
(b) pin -> trailing space to superview
(c) pin -> top space to superview
因為高度不固定,所以我沒設定
但也因此出現了warning: Ambiguous layout: height is ambiguous for image view.
可是就高度不固定啊~"~
這樣要怎樣解決呢QQ|||
阿 找到這一篇有解答
http://forums.macrumors.com/showthread.php?t=1489373
※ 編輯: issuemylove 來自: 211.21.125.247 (01/13 19:34)
※ 編輯: issuemylove 來自: 211.21.125.247 (01/13 19:39)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章