我需要创建一个“旧”风格的UIView,没有自动版式和约束。在我看来,有一个表格视图是用自动布局和另一个视图来计算它的大小。不幸的是,它看起来似乎并不能提供我需要的高度。这是我正在创建了UIView:增加高度,而不会自动布局
// View 1 - Calendar View
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, height)];
calendar.dataSource = self;
calendar.delegate = self;
calendar.scopeGesture.enabled = YES;
[view addSubview:calendar];
// View 2 - TableView
_myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
self.myTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
self.myTableView.tableFooterView = [UIView new];
self.myTableView.backgroundColor = self.view.backgroundColor;
[self.myTableView setShowsHorizontalScrollIndicator:NO];
[self.myTableView setShowsVerticalScrollIndicator:NO];
// self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.myTableView.estimatedRowHeight = 85.0;
self.myTableView.rowHeight = UITableViewAutomaticDimension;
_myTableView.bounces = NO;
self.myTableView.dataSource = self;
self.myTableView.delegate = self;
self.myTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
if (SYSTEM_VERSION_GREATER_THAN(@"8.4") && (IS_IPAD)){
self.myTableView.cellLayoutMarginsFollowReadableWidth = NO;
}
[self.view addSubview:_myTableView];
我猜想问题可能出在这里:
_myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
因为,我失去了约200点的空间(y位置,我想以编程方式移动表视图向下)。
有什么办法,以适应屏幕高度,以我的看法?
在哪个方法中你写这段代码? –
@JayeshThanki在视图中加载 –
我没有得到你为什么以200作为y原点在“_myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,200,SCREEN_WIDTH,SCREEN_HEIGHT)style:UITableViewStylePlain]; ”? 要么使200为0或SCREEN_HEIGHT至(SCREEN_HEIGHT-200)。希望这可以帮助。 –