调整表格视图的大小

pie*_*ier 3 iphone resize uitableview

我正在寻找一种方法,让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];
}
Run Code Online (Sandbox Code Playgroud)

问题是与tableview,似乎调整大小不起作用,所以我看不到所有的结果.

谢谢你的建议.

alb*_*amg 5

如果要管理的视图由多个子视图组成,则应使用UIViewController子类而不是UITableViewController管理表视图,其中一个是子视图.您可以添加UITableView子视图并使控制器实现UITableViewDelegateUITableViewDataSource协议.

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

表格视图的iOS编程指南:

注意:如果要管理的视图由多个子视图组成,其中一个是表视图,则应使用UIViewController子类而不是UITableViewController的子类来管理表视图.UITableViewController类的默认行为是使表视图填充导航栏和选项卡栏之间的屏幕(如果存在).

如果您决定使用UIViewController子类而不是UITableViewController的子类来管理表视图,那么您应该执行上面提到的一些任务以符合人机界面指南.要在显示之前清除表视图中的任何选择,请通过调用deselectRowAtIndexPath:animated:来实现viewWillAppear:方法以清除所选行(如果有).显示表视图后,您应该通过向表视图发送flashScrollIndicators消息来闪烁滚动视图的滚动指示器; 您可以在UIViewController的viewDidAppear:方法的覆盖中执行此操作.