I am developing iOS App.
I use tableView in a view in Storyboard(Auto layout). In the storyboard, the height of the tableView is set in 568px.
I would like to change the height depending on the size of screen.
I am writing down the following code, however I can't.
@property (weak, nonatomic) IBOutlet UITableView *tableView;
- (void)viewDidLoad
{
UIScreen *sc = [UIScreen mainScreen];
CGRect rect = sc.applicationFrame;
self.tableView.frame = CGRectMake(0,0,rect.size.width,rect.size.height);
}
Could you tell me how to implement?
由于您使用的是自动布局,因此可以给tableview约束,top和bottom = 0,以便其高度始终等于其容器的高度
To set following constraints that will help UITableView
to occupied whole screen.
Leading Space = 0 from mainView
Top Space = 0 from mainView
Bottom Space = 0 from mainView
Trailing Space = 0 from mainView
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.