gpt4 book ai didi

iphone - 调整表格 View 大小

转载 作者:行者123 更新时间:2023-12-03 19:39:22 25 4
gpt4 key购买 nike

我正在寻找一种方法,让 UITableViewController 的顶部有一个 UITableView,下面有一个 UIPickerView(具有固定位置)。

我找到了使用以下代码修复选择器的解决方案:

- (void)viewDidLoad {
[super viewDidLoad];

_picker = [[UIPickerView alloc] initWithFrame:CGRectZero];
_picker.showsSelectionIndicator = YES;
_picker.dataSource = self;
_picker.delegate = self;

// Add the picker to the superview so that it will be fixed
[self.navigationController.view addSubview:_picker];

CGRect pickerFrame = _picker.frame;
pickerFrame.origin.y = self.tableView.frame.size.height - 29 - pickerFrame.size.height;

_picker.frame = pickerFrame;

CGRect tableViewFrame = self.tableView.frame;
tableViewFrame.size.height = 215;

self.tableView.frame = tableViewFrame;

[_picker release];
}

问题出在表格 View 上,调整大小似乎不起作用,所以我看不到所有结果。

感谢您的建议。

最佳答案

如果要管理的 View 由多个 subview 组成,其中一个是 TableView ,则应使用 UIViewController 子类而不是 UITableViewController 来管理 TableView 。您可以添加 UITableView subview ,并使 Controller 实现 UITableViewDelegateUITableViewDataSource 协议(protocol)。

UITableViewController 类的默认行为是使表格 View 填充导航栏和选项卡栏(如果存在)之间的屏幕。

来自Table View Programming Guide for iOS :

Note: You should use aUIViewController subclass rather thana subclass of UITableViewController tomanage a table view if the view to bemanaged is composed of multiplesubviews, one of which is a tableview. The default behavior of theUITableViewController class is to makethe table view fill the screen betweenthe navigation bar and the tab bar (ifeither are present).

If you decide touse a UIViewController subclass ratherthan a subclass ofUITableViewController to manage atable view, you should perform acouple of the tasks mentioned above toconform to the human-interfaceguidelines. To clear any selection inthe table view before it’s displayed,implement the viewWillAppear: methodto clear the selected row (if any) bycalling deselectRowAtIndexPath:animated:.After the table view has beendisplayed, you should flash the scrollview’s scroll indicators by sending aflashScrollIndicators message to thetable view; you can do this in anoverride of the viewDidAppear: methodof UIViewController.

关于iphone - 调整表格 View 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6432088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com