iphone - 根据Tapku日历高度设置UITableView frame

标签 iphone ios calendar

我在它下面有 Tapku 日历和表格 View 。日历没有静态高度,它取决于其中的行数,不同月份有所不同。就像几个月里有 5 行,有些是 6 行。我想设置表格框架,它应该从日历结束的地方开始。我尝试了下面提到的方法,但不起作用。

- (void)calendarMonthView:(TKCalendarMonthView *)monthView monthDidChange:(NSDate *)d {
NSLog(@"calendarMonthView monthDidChange:%@",d);

  [self.mTableView setFrame:CGRectMake(0, calendar.frame.origin.y + calendar.frame.size.height, 320, 308 - calendar.frame.size.height - calendar.frame.origin.y)];
  [self.mTableView reloadData];

NSLog(@"calendar height:%f", calendar.frame.size.height);
}

它在控制台中打印日历高度:0.000000。 以上请指导。

最佳答案

如果这仍然与您相关,请从 TapkuLibrary 中 UI>Calendar>Month 下的 TKCalendarMonthTableViewController.m 文件中尝试此操作,它对我有用,我遇到了与您完全相同的问题:

- (void)calendarMonthView:(TKCalendarMonthView *)monthView monthDidChange:(NSDate *)month animated:(BOOL)animated {
    [self updateTableOffset:animated];
}

- (void) updateTableOffset:(BOOL)animated{

    if(animated){
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.4];
        [UIView setAnimationDelay:0.1];
    }


    float y = self.monthView.frame.origin.y + self.monthView.frame.size.height;
    self.tableView.frame = CGRectMake(self.tableView.frame.origin.x, y, self.tableView.frame.size.width, self.view.frame.size.height - y );
    if(animated) [UIView commitAnimations];
}

要从头开始调整高度,在loadView上,我只是在初始化日历后选择了日期:

calendar =  [[TKCalendarMonthView alloc] initWithSundayAsFirst:NO];
[calendar selectDate:[NSDate date]];

这样框架不仅在 monthDidChange 之后调整..

希望对您有所帮助!

关于iphone - 根据Tapku日历高度设置UITableView frame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17307915/

相关文章:

iphone - 页脚背景未在 iPhone 上显示

ios - Xcode6 USB 安装 - 设备上的策略禁止配对

android - 获取当月过去几周的日期

java - 上个月的月结束日期(不含 JODA)

ios - 在 UITableView 中默认重新加载后如何记住选择的行并维护它们?

ios - 调试 iOS 应用程序 : crash under Xcode but keep working on iPhone

iphone - 更改 UIImageView 动画速度

iOS Swift 1秒后更新文本标签

ios - Swift - 如何查找数组中数组中项目的索引

android - 在 Android sdk 警报管理器中的选定日期重复计划任务