我想使用 UIExpandableTableView - https://github.com/OliverLetterer/UIExpandableTableView#readme。
我遇到了一个问题,因为它唯一的初始化程序是initWithFrame
:
#pragma mark - Initialization
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
if ((self = [super initWithFrame:frame style:style])) {
self.maximumRowCountToStillUseAnimationWhileExpanding = NSIntegerMax;
self.expandableSectionsDictionary = [NSMutableDictionary dictionary];
self.showingSectionsDictionary = [NSMutableDictionary dictionary];
self.downloadingSectionsDictionary = [NSMutableDictionary dictionary];
self.animatingSectionsDictionary = [NSMutableDictionary dictionary];
}
return self;
}
我一直在尝试从 Storyboard 初始化 tableView 并意识到我看到的错误是因为它initWithFrame
从未被调用并且NSMutableDictionaries
没有被初始化。如何解决这个问题?
如果不容易解决,我可以以编程方式实例化并使用initWithFrame
,但除了想使用 Storyboard 之外,我也很好奇解决方案会是什么。
编辑以下是这些属性及其 ivars 在 UIExpandableTableView 中的声明方式。这是在 .h 文件中:
@interface UIExpandableTableView : UITableView <UITableViewDelegate, UITableViewDataSource, NSCoding> {
@private id __UIExpandableTableView_weak _myDelegate; id __UIExpandableTableView_weak _myDataSource;
NSMutableDictionary *_expandableSectionsDictionary; // will store BOOLs for each section that is expandable
NSMutableDictionary *_showingSectionsDictionary; // will store BOOLs for the sections state (nil: not expanded, 1: expanded)
NSMutableDictionary *_downloadingSectionsDictionary; // will store BOOLs for the sections state (nil: not downloading, YES: downloading)
NSMutableDictionary *_animatingSectionsDictionary;
NSInteger _maximumRowCountToStillUseAnimationWhileExpanding;
BOOL _onlyDisplayHeaderAndFooterViewIfTableViewIsNotEmpty;
UIView *_storedTableHeaderView;
UIView *_storedTableFooterView;
}
这是 UIExpandableTableView 的 .m 文件的顶部。吨
@interface UIExpandableTableView ()
@property (nonatomic, retain) NSMutableDictionary *expandableSectionsDictionary;
@property (nonatomic, retain) NSMutableDictionary *showingSectionsDictionary;
@property (nonatomic, retain) NSMutableDictionary *downloadingSectionsDictionary;
@property (nonatomic, retain) NSMutableDictionary *animatingSectionsDictionary;
@property (nonatomic, retain) UIView *storedTableHeaderView;
@property (nonatomic, retain) UIView *storedTableFooterView;
- (void)downloadDataInSection:(NSInteger)section;
- (void)_resetExpansionStates;
@end