Reputation: 403
I'm having an issue while trying to resize my cell on iOS 8 - I've just updated and it was working fine on iOS 7.
I'm not using auto-layout on this project.
-(void)layoutSubviews{
[super layoutSubviews];
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
//When the user is on iPhone/iPod, we need to inset the cell =/
CGRect frame = self.frame;
if(frame.origin.x == 0){
CGFloat offset = 25;
frame.size.width -= offset;
frame.origin.x += (offset/2);
[self setFrame:frame];
if (IS_IPHONE) {
self.emptyLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
}
}
}
}
That code should be taking the cell's origin.x
to 12.5px, but it seems that on iOS 8 the origin part of code is just ignored as it returns to 0px, and the size part works normally.
Does anyone knows how to solve this issue? Thanks in advance.
Here's a screenshot of the issue:
Upvotes: 0
Views: 441
Reputation: 403
The problem was not on the frame config... but on the animation:
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
For some reason on iOS8 this animation ignores the frame i set up previously.
Now The solution!
I've created a category from UITableView (UITableView+Animation), and created this method inside:
- (void)reloadDataAnimated:(BOOL)animated
{
[self reloadData];
if (animated) {
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setFillMode:kCAFillModeForwards];
[animation setDuration:.2];
[[self layer] addAnimation:animation forKey:@"UITableViewReloadDataAnimationKey"];
}
}
Then i've imported the category and call this method instead of the normal reloadData.
[self.tableView reloadDataAnimated:YES]; // This method animates
[self.tableview reloadData]; //This method is the normal reload
I've found this solution here on StackOverflow on some other question i don't remember. Sorry i could't give the proper credits !
Upvotes: 1