2015-08-02 4 views
1

У меня есть таблица с использованием ios 8.0+, я добавил флажок для каждой ячейки - на iphone 5 отлично работает, но при тестировании на iphone 6 - флажок справа положение только после прокрутки ... (второе изображение после прокрутки)ios - просмотр позиции внутри ячейки tableview изменяется только после прокрутки

**** can not добавить фотографии еще :) так что я действительно вижу при первой загрузке, так это то, что флажок имеет несколько правых клавиш -> после прокрутки некоторые из флажков перемещаются вправо - где они должны быть Код ниже Спасибо!

CGFloat y =self.navigationController.navigationBar.frame.size.height + self.navigationController.navigationBar.frame.origin.y; 
tableData = [[UITableView alloc] initWithFrame:CGRectMake(5, y+10, self.view.frame.size.width, self.view.frame.size.height - y -30 - nextButton.frame.size.height -10) style:UITableViewStylePlain]; 
tableData.dataSource = self; 
tableData.delegate = self; 



[self.view addSubview:tableData]; 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

    } 
    else 
    { 
     CTCheckbox *check = [cell.subviews objectAtIndex:1]; 
     [check removeFromSuperview]; 
    } 






CTCheckbox *checkbox; 

cell.contentView.backgroundColor = [UIColor grayColor]; 
checkbox = [[CTCheckbox alloc] initWithFrame:CGRectMake(cell.frame.size.width-60, cell.frame.size.height/2-10, 50, 20.0)]; 
checkbox.alpha = 0.7; 
[checkbox addTarget:self action:@selector(checkboxDidChange:) forControlEvents:UIControlEventValueChanged]; 
checkbox.tag = indexPath.row; 
[checkbox setColor:[BlendedColors pink] forControlState:UIControlStateNormal]; 

//Expertise label 
UIFont *myFont = [UIFont systemFontOfSize:12.0 ]; 
cell.textLabel.font = myFont; 

cell.textLabel.text = [experties objectAtIndex:indexPath.row]; 
cell.textLabel.textColor = [BlendedColors black]; 
[cell addSubview:checkbox]; 
cell.selectionStyle = UITableViewCellStyleDefault; 


if([[selectedCheckBox objectAtIndex:indexPath.row]isEqualToString:@"YES"]) 
{ 
    checkbox.checked = YES; 
} 
else{ 
    checkbox.checked = NO; 
} 


//cell.contentView.backgroundColor = [UIColor blackColor]; 
return cell; 

}

ответ

0

Fixed - Первая ширина ячейки всегда 320

добавили 3 линии

if (cell == nil) { 

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    //Fix Bug - first cell view is always 320 - now its dynamic(cell width = device width) 
     CGRect cellFrame = cell.frame; 
     cellFrame.size.width = self.view.frame.size.width; 
     cell.frame = cellFrame; 


    }