表视图无法正确加载

时间:2015-02-05 10:55:49

标签: iphone uitableview swift uiimageview

我想建立一个圆形轮廓图像。并使用以下代码:

//Void func that sets the set style
func setCellStyle(){
    // set border Width
    self.profileImageView.layer.borderWidth = 3.0
    self.profileImageView.layer.cornerRadius =     self.profileImageView.frame.size.width/2
    self.profileImageView.clipsToBounds = true
}

加载应用后,我遇到以下问题:

App just after loading screenshot

前几个单元格出现了指示的红色问题,而绿色单元格出现了我的预期。在查看tableview后,它将错误的单元格更新为预期的单元格。我想加载这个,所有的imageViews都是绿色的!

有人能帮助我吗? 此致

1º编辑:

从绿色指示器中可以看出,我可以循环播放。问题出现在第一个单元格中,在启动时它们像红色指示器一样加载。

故事板截图: https://drive.google.com/file/d/0B_3MBkUrHOuRSWlzTmFENGJSOFU/view?usp=sharing

HomeViewController(cellForRowAtIndexPath方法): https://drive.google.com/file/d/0B_3MBkUrHOuRNWd2TVcyNVluVWs/view?usp=sharing

问候!

2º编辑:

在这里找到anwser:How to change UITableViewCell Image to Circle in UITableView

2 个答案:

答案 0 :(得分:2)

当您尝试对图像进行舍入时,似乎您的自动布局尚未配置个人资料图像的最终帧。尝试在<{1}}

自动布局完成后进行舍入

答案 1 :(得分:0)

*试试圆形轮廓图像

func setCellStyle(){
  self.profileImageView.image=[UIImage imageNamed:@"Your Image name"];
//set round shape image
  self.profileImageView.layer.cornerRadius =self.profileImageView.frame.size.height /2;
}