【发布时间】:2023-10-30 04:48:01
【问题描述】:
我正在使用以下代码以编程方式创建搜索栏和表格视图
UISearchBar* searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0,320,40)];
searchBar.delegate = self;
[self.view addSubview:searchBar];
UITableView* tblView = [[UITableView alloc]initWithFrame:CGRectMake(0, 41, 320, 400)];
tblView.delegate = self;
tblView.dataSource = self;
[self.view addSubview:tblView];
现在我在以下方法中设置了返回值 yes 来旋转屏幕 wrt 设备方向
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
我在loadView中使用了以下代码
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
以下是我的输出
但是在横向模式下,搜索栏和表格视图仍然不适合屏幕,我应该怎么做任何人都可以帮助我,谢谢提前
【问题讨论】:
-
*.com/q/7256785/491980 的完全重复
标签: iphone objective-c xcode landscape uiinterfaceorientation