Tôi đang cố truy cập chiều cao của TableViewCell bên trong setProperty của ô.Nhận chiều cao hàng cập nhật trong ô sau khi heightForRowAtIndexPath
tôi là tạo ra các tế bào thông qua xib và sau đó thay đổi chiều cao dựa trên giá trị trả lại trong heightForRowAtIndexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 200;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
RightGuideCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
cell.ticks = @[@"1",@"1",@"1",@"1",@"1",@"1",@"1"];
return cell;
}
này là tài sản trong di động của tôi.
- (void)setTicks:(NSArray *)ticks {
_ticks = ticks;
CGFloat height = self.frame.size.height; //Value is 44 (size in xib)
}
Làm cách nào để nhận 200 (đặt trong heightForRowAtIndexPath
) trong ô?
Chiều cao đã được tính toán trong cellForRowAtIndexPath, vì vậy bạn có thể cần phải tải lại ô sau này. Điều đó sẽ có được chiều cao mới nhưng có thể là loại ressource-nặng. – Tobias