Re: [心得] 開發了一個月的 iOS 小作品

作者: kokuyoku (天龍狂想曲)   2015-07-07 09:49:05
在文中發現你對 xib 或 storyboard 的 cell 不能動態決定高度有問題
我自己都是用 storyboard 建 cell 畫面 裡面都是用 Autolayout 處理子畫面的位置
然後要計算各個 table view row height 時主要會用到下面這一部份
http://i.imgur.com/z0cla4a.png
其中 - setupCellData: atIndexPath: 是在 cell 裡塞入資料的 method
以下是 method 部份程式碼
- (void)setupCellData:(CouponListTableViewCell *)cell
atIndexPath:(NSIndexPath *)indexPath {
CouponEntity *couponData = self.couponDatas[indexPath.row];
cell.storeNameLabel.text = couponData.store_name;
....
....
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
storyboard 裡畫面則是長這樣
http://i.imgur.com/8EXoM8V.png
比較特別的是 store name label 可以多行呈現 + 「右邊有一個button」
畫面元件左右邊有其它畫面元件時的畫面延展壓縮又是另一個故事了

Links booklink

Contact Us: admin [ a t ] ucptt.com