i use custom UITableViewCell in a UITableView. In this custom cell i have a UIView(renkView) which contains an UILabel(haberCatLbl). i change the width and position of that UIView according to UILabel's width. but the problem that i face is whenever i run the application first two cells which are visible cells doesn' t change that UIView's position and width but whenever i scroll the UITableView down and up then the UIView takes the frame that it has to. what can be wrong here ? here my codes are.
beside that i used layoutSubviews method in HaberCell.m file to resize the View but still same problem. how can i fix that problem ?
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"HaberCell";
HaberCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil)
{
cell = [[HaberCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
Haber *currentHaber = [self.arrHaberler objectAtIndex:indexPath.row];
UIColor *bgColor = [self.arrColors objectAtIndex:(indexPath.row) % 7];
NSString *categoryTitle = currentHaber.haberCategory;
CGSize titleLength = [categoryTitle sizeWithFont:[UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:10] constrainedToSize:CGSizeMake(9999, 20)];
cell.renkView.frame = CGRectMake(306 - (titleLength.width+10), 16, titleLength.width+10, 20);
cell.renkView.backgroundColor = bgColor;
cell.haberCatLbl.text = currentHaber.haberCategory;
cell.haberCatLbl.font = [UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:10];
cell.haberCatLbl.backgroundColor = [UIColor clearColor];
return cell;
}
- (void)viewDidAppear:(BOOL)animated
{
[self.tblHaberler reloadData];
[super viewDidAppear:animated];
}
beside that i used layoutSubviews method in HaberCell.m file to resize the View but still same problem. how can i fix that problem ?