feat:List and slider support wrap content in iOS

This commit is contained in:
pengfei.zhou
2019-11-19 17:49:08 +08:00
parent 06f2a0b106
commit f2d2c96619
2 changed files with 37 additions and 4 deletions

View File

@@ -29,6 +29,23 @@ @interface DoricTableViewCell : UITableViewCell
@implementation DoricTableViewCell
@end
@interface DoricTableView : UITableView
@end
@implementation DoricTableView
- (CGSize)sizeThatFits:(CGSize)size {
if (self.subviews.count > 0) {
CGFloat width = size.width;
for (UIView *child in self.subviews) {
width = MAX(child.width, width);
}
return CGSizeMake(width, size.width);
}
return size;
}
@end
@interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSString *> *itemViewIds;
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSNumber *> *itemHeights;
@@ -47,7 +64,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext {
}
- (UITableView *)build {
return [[UITableView new] also:^(UITableView *it) {
return [[DoricTableView new] also:^(UITableView *it) {
it.dataSource = self;
it.delegate = self;
it.separatorStyle = UITableViewCellSeparatorStyleNone;