Skip to content

Instantly share code, notes, and snippets.

@SeptiyanAndika
Forked from booiiing/IntrinsicTableView.h
Created May 3, 2016 10:38
Show Gist options
  • Save SeptiyanAndika/38bbf6d1c7419540a1d182bf3411e5e6 to your computer and use it in GitHub Desktop.
Save SeptiyanAndika/38bbf6d1c7419540a1d182bf3411e5e6 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface IntrinsicTableView : UITableView
@end
#import "IntrinsicTableView.h"
@implementation IntrinsicTableView
- (CGSize)intrinsicContentSize {
[self layoutIfNeeded];
return CGSizeMake(UIViewNoIntrinsicMetric, self.contentSize.height);
}
- (void)endUpdates {
[super endUpdates];
[self invalidateIntrinsicContentSize];
}
- (void)reloadData {
[super reloadData];
[self invalidateIntrinsicContentSize];
}
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
[super reloadRowsAtIndexPaths:indexPaths withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation {
[super reloadSections:sections withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation {
[super insertSections:sections withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation {
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation {
[super deleteSections:sections withRowAnimation:animation];
[self invalidateIntrinsicContentSize];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment