storyboradにて、UITableViewにUITableViewCellを配置し、cell内のimageViewの高さを
autolayoutで可変(画面サイズによって)にしています。
この時、コードの中で、そのimageViewを正円にしようとしているのですが
imageView.frameのサイズが初回描写時とスクロールした時で異なっていて、
初回描写時だけうまく正円にならず、困っています。
tableViewをスクロールすると、再描写?して正円になり、以降はずっと正円となります。
func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeReusableCellWithIdentifier("sampleCell", forIndexPath: indexPath)
let imageView = cell.viewWithTag(1) as ! UIImageView
・・・
// 画像を正円にする
print(imageView.frame.size.height) // ←初回とスクロール時で値が異なる。(初回のみ82、以降は64)
imageView.layer.cornerRadius = (imageView.frame.size.height * 0.5)
imageView.layer.masksToBounds = true
}
初回から正しく正円にするため、imageViewのサイズを正しく取れる方法はありますでしょうか。