You can use the NSNotificationCenter to post a notification to inform each cell to change the width of that specific view.
When a cell is created you can register it to a specific notification:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:@"Notification"
object:nil];
Then you can handle in each cell the notification and make the changes you need:
- (void) receiveNotification:(NSNotification *) notification
{
CGRect newFrame = CGRectMake(0.0,0.0,10.0,0.0); // different frame width
[UIView animateWithDuration:0.5 animations:^{
self.block.frame = updatedFrame; // where block is the custom subview
}];
}
When you want to change the width you only need to post the event.
[[NSNotificationCenter defaultCenter]
postNotificationName:@"Notification"
object:self];
Do not forget to reuse each cell and when the cell is deallocated make sure you unregister that event.
[[NSNotificationCenter defaultCenter] removeObserver:self];