我在它下面有 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/