【问题标题】:How can I resize the table view in a UITableView controller?如何在 UITableView 控制器中调整表格视图的大小?
【发布时间】:2011-11-13 19:05:52
【问题描述】:

我有一个UINavigationController,其中包含UITableViewController 的视图。如何在导航控制器中调整表格视图的大小?

【问题讨论】:

    标签: iphone ios uitableview sdk tableview


    【解决方案1】:

    不完全确定这是否是您正在寻找的,但它听起来足够接近。这会将您的 tableView 调整为您指定的任何像素大小。它也会在过渡中完成(所以它不会只是跳转到大小)。如果需要,您可以删除过渡。

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    
    CGRect rect = myTableView.frame;
    rect.size.height = 400;
    rect.size.width = 300;
    myTableView.frame = rect;
    [UIView commitAnimations];
    

    【讨论】:

    • 这是我用来在我的应用程序中调整表格视图大小的确切代码。不知道为什么你的不工作。
    【解决方案2】:
    [[self tableView] setFrame:CGRectMake(0, 0, 320, 480)];
    

    【讨论】:

      【解决方案3】:

      也许这种方法会帮助您调整表格行的大小:

      - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
      

      【讨论】:

        猜你喜欢
        • 2013-07-08
        • 2012-06-29
        • 1970-01-01
        • 2013-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-08
        相关资源
        最近更新 更多