i have a custom UITableviewCell xib, connected with my uitableview, and i’ll do it in this way:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MyCustomCell" owner:self options:nil];
cell = myCell;
self.myCell = nil;
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
then when change the orientation of the device, i want change the position of some element in my custom UITableViewCell so in this method:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
CGRect myframe = CGRectMake(600, self.arrowLabel.frame.origin.y, self.arrowLabel.frame.size.width, self.arrowLabel.frame.size.height);
self.arrowLabel.frame = myframe;
} else {
CGRect myframe = CGRectMake(400, self.arrowLabel.frame.origin.y, self.arrowLabel.frame.size.width, self.arrowLabel.frame.size.height);
self.arrowLabel.frame = myframe;
}
}
i change the frame.origin.y and frame.origin.y of my arrowLabel connected with my UITableViewCell xib but change only the position of the last row of the tableview, the other label in the other row remain in the same position, so my question is how i can reload the table view?…i have also tried with [self.tableview reloadData];…but don’t work…any idea?
You may want to try putting the frame change codes in your
cellForRowAtIndexPath. Basically in that method you have something like:And then in your
willRotatemethod you can call[tableView reloadData].Edit: