【问题标题】:Placing a fixed position toolbar in a Split View Controller's root view在拆分视图控制器的根视图中放置固定位置工具栏
【发布时间】:2011-03-17 21:09:11
【问题描述】:

我在为拆分视图 IPad 应用程序在根视图控制器中放置工具栏时遇到问题。我尝试减小表格视图的大小并在其下方放置一个工具栏,但没有进行框架调整,工具栏最终会随着表格滚动,而不是像我想要的那样停留在屏幕底部。

这是我在 viewDidLoad 中使用的代码:

self.tableView.frame = CGRectMake(0, searchBar.bounds.size.height, 320, 655 - searchBar.bounds.size.height);

UIToolbar *toolbar = [UIToolbar new]; toolbar.barStyle = UIBarStyleBlack;

toolbar.frame = CGRectMake(0, 655, 320, 50);

[self.view addSubview:toolbar];

谢谢。

【问题讨论】:

    标签: ipad


    【解决方案1】:

    找到了解决这个问题的好方法,代码如下:

    [super viewWillAppear: animated];
    
    toolbar = [[UIToolbar alloc] init]; toolbar.barStyle = UIBarStyleBlack;
    toolbar.frame = CGRectMake(0, 0, 320, 49);
    [toolbar sizeToFit];
    
    CGFloat toolbarHeight = 49;
    CGRect rootViewBounds = self.parentViewController.view.bounds;
    CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);
    CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);
    
    CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
    
    [toolbar setFrame:rectArea];
    
    [self.navigationController.view addSubview:toolbar];
    
    [[self tableView] reloadData];
    

    【讨论】:

    • 而工具栏的父级是一个uinavigationcontroller?
    猜你喜欢
    • 2014-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多