![](/img/trans.png)
[英]How to align UITableViewCell to the bottom of the UITableView?
[英]How to align the UITableViewCell imageview to the edge of the UITableView
您好,我在UITableViewCell
中使用本機UITableView
。 當我設置單元格的圖像時,它看起來像圖像視圖未與UITableViewCell
的第0 x
位置對齊。 UITableView
與cell.imageView
之間存在間隙或填充。 我確實在cellForRowAtIndex
CGRect imgRect=cell.imageView.frame;
imgRect.origin.x=0;
cell.imageView.frame=imgRect;
但還是一樣。 沒有改變。 如何將單元格圖像對齊到桌子的邊緣。 請幫我。 謝謝
要將圖像視圖與內容視圖的前端對齊,首先需要創建自定義UITableviewCell,然后按照以下步驟創建子類(請參閱創建自定義tableviewcell的鏈接 )
選擇“文件”>“新建”>“文件”(或按Command-N鍵)。
在出現的對話框的左側,選擇iOS下的Source。
選擇“可可接觸類”,然后單擊“下一步”。
在“子類”字段中,選擇UITableViewCell並創建名為“ CustomTableViewCell”的表視圖子類。
打開情節提要,在大綱視圖中,選擇“表視圖單元格”。
打開身份檢查器。 找到標記為Class的字段,然后從列表中選擇“ CustomTableViewCell”。
完成tableviewcell后,拖動imageview並設置頂部,底部和通向單元格內容視圖的約束,並將常數保持為0。為imageview添加高度和寬度約束。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.