如何调整UITableView在UITableViewController与节头 [英] How to resize UITableView in UITableViewController with section header

查看:91
本文介绍了如何调整UITableView在UITableViewController与节头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UITableViewController中有一个分组的UITableView,我想要横向调整它的大小。



我尝试了很多不同的方式,但没有一个是完美的。 />



我尝试过的:



1)覆写 UITableView setFrame:] ,但它没有移动节的头部,并且两侧都有黑色区域(因为表视图后面没有任何东西)。



2。)覆盖 - [UITableViewCell setFrame:] ,但它仍然不移动标题(这很重要) p>

3。)从UITableViewController调用 - [self.view setFrame:] ,但它什么都不做。 / p>

如果您有任何想法,请与我分享。

解决方案

如果您从 - [UITableViewController viewDidAppear:] 调用 - [UITableView setFrame:] 工程:

   - (void)viewDidAppear:(BOOL)animated 
{
[self.tableView setFrame :CGRectMake(x,y,w,h)];
}

为了避免在表视图的每一侧出现黑条,应用程序主窗口的背景颜色为白色:

  [[[UIApplication sharedApplication] keyWindow] setBackgroundColor:[UIColor whiteColor] ; 


I've got a grouped UITableView in a UITableViewController and I want to resize it horizontally.

I tried many different ways but none of them was perfect.

What I've tried:

1.) Overriding - [UITableView setFrame:], but it didn't move the headers of the sections and there are black areas on both sides (because there isn't anything behind the table view).

2.) Overriding - [UITableViewCell setFrame:], but it still doesn't move the headers (which is important).

3.) Calling - [self.view setFrame:] from UITableViewController, but it doesn't do anything.

If you've got any idea how to solve it please share it with me!

解决方案

If you call - [UITableView setFrame:] from - [UITableViewController viewDidAppear:], it works:

- (void)viewDidAppear:(BOOL)animated
{
    [self.tableView setFrame:CGRectMake(x, y, w, h)];
}

In order to avoid having black bars on each side of the table view, set the background color of the application's main window to white:

[[[UIApplication sharedApplication] keyWindow] setBackgroundColor:[UIColor whiteColor]];

这篇关于如何调整UITableView在UITableViewController与节头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆