André Dos Santos
André Dos Santos

Reputation: 833

Table View Doesn't load properly

I want to build a round shape profile image. And used the following code:

//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
}

After loading the app i have the following issue:

App just after loading screenshot

The first few cells come with the indicated red issue and the green ones come as i expected. After going up in the tableview it updates my wrong cells to the expected. I want to load this and all imageViews come as the green one!

Can someone help me? Regards

1º Edit:

As you can see from the green indicator, i can do it circular. The problem comes in the first cells, at launch they load like the red indicator.

Storyboard screenshot: https://drive.google.com/file/d/0B_3MBkUrHOuRSWlzTmFENGJSOFU/view?usp=sharing

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

Regards!

2º edit:

Found anwser here: How to change UITableViewCell Image to Circle in UITableView

Upvotes: 0

Views: 113

Answers (2)

iTeam
iTeam

Reputation: 1

*Try This for round shape profile image

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

Upvotes: 0

Ahmed Belal Hashmi
Ahmed Belal Hashmi

Reputation: 121

It seems like your autolayout has not configured the final frame for the profile image when you try to round the image. Try to do the rounding after autolayout is finished, in viewDidLayoutSubviews

Upvotes: 2

Related Questions