作者:无与伦比的美丽MJ | 来源:互联网 | 2023-08-21 10:19
IhaveaUIViewwhichcontainsaUITableView.ThetableviewsdelegateissettomyUIView,butitn
I have a UIView which contains a UITableView. The tableview's delegate is set to my UIView, but it never calls the delegate methods:
我有一个包含UITableView的UIView。 tableview的委托设置为我的UIView,但它从不调用委托方法:
-(id)init {
self = [super init];
if (self) {
self.tableView = [[UITableView alloc] initWithFrame:self.bounds];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.scrollEnabled = NO;
self.tableView.layer.cornerRadius = PanelCornerRadius;
[self addSubview:self.tableView];
}
return self;
}
#pragma mark - UITableViewDelegate methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"height for row");
int height = [self heightForRowAtIndexPath:indexPath];
return height;
}
#pragma mark - UITableViewDataSource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"number of rows");
if (self.manager.fetchOperation.dataFetchProblem) {
return 1;
}
int numberOfRows = [self.delegate numberOfSectionsInPanel:self];
return numberOfRows;
}
I've explored every option I can think of, but can't seem to find the root of the problem.
我已经探索了我能想到的每一个选项,但似乎无法找到问题的根源。
EDIT: Included the numberOfRowsInSection. It could potentially return 0, only it never gets that chance because the "number of rows" NSLog never gets called.
编辑:包括numberOfRowsInSection。它可能会返回0,只有它永远不会有机会,因为“行数”NSLog永远不会被调用。
7 个解决方案