mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/forceConversationCellLayout'
This commit is contained in:
commit
b3d9363961
|
@ -35,10 +35,53 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
_isCellVisible = isCellVisible;
|
_isCellVisible = isCellVisible;
|
||||||
|
|
||||||
if (isCellVisible) {
|
if (isCellVisible) {
|
||||||
[self layoutIfNeeded];
|
[self forceLayoutImmediately];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setFrame:(CGRect)frame
|
||||||
|
{
|
||||||
|
BOOL didSizeChange = CGSizeEqualToSize(self.frame.size, frame.size);
|
||||||
|
|
||||||
|
[super setFrame:frame];
|
||||||
|
|
||||||
|
if (didSizeChange) {
|
||||||
|
[self forceLayoutImmediately];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setBounds:(CGRect)bounds
|
||||||
|
{
|
||||||
|
BOOL didSizeChange = CGSizeEqualToSize(self.bounds.size, bounds.size);
|
||||||
|
|
||||||
|
[super setBounds:bounds];
|
||||||
|
|
||||||
|
if (didSizeChange) {
|
||||||
|
[self forceLayoutImmediately];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)forceLayoutImmediately
|
||||||
|
{
|
||||||
|
NSArray<UIView *> *descendents = [ConversationViewCell collectSubviewsOfViewDepthFirst:self];
|
||||||
|
for (UIView *view in descendents) {
|
||||||
|
[view setNeedsLayout];
|
||||||
|
}
|
||||||
|
for (UIView *view in descendents.reverseObjectEnumerator) {
|
||||||
|
[view layoutIfNeeded];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray<UIView *> *)collectSubviewsOfViewDepthFirst:(UIView *)view
|
||||||
|
{
|
||||||
|
NSMutableArray<UIView *> *result = [NSMutableArray new];
|
||||||
|
for (UIView *subview in view.subviews) {
|
||||||
|
[result addObjectsFromArray:[self collectSubviewsOfViewDepthFirst:subview]];
|
||||||
|
}
|
||||||
|
[result addObject:view];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
Loading…
Reference in a new issue