与此issue这么多小时处理没有任何的运气后的正确尺寸,我在我的UIViewController
的编程的loadView创建视图尝试不同的方法。我有我的UIViewController
UIToolbar
和UITableView
,但我有麻烦施胶添加视图作为另一个UIView
的子视图时。这里就是我有这么远:UIViewController的视图
在我的自定义的UIViewController”的loadView:
{
[super loadView];
//this doesn't seem right!?!?
self.view.frame = CGRectMake(0, 0, 400, 300);
//create the Tool Bar
self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 45.01)];
[self.toolbar setBarStyle:UIBarStyleDefault];
[self.toolbar setAutoresizesSubviews:TRUE];
[self.toolbar setAutoresizingMask:(UIViewAutoresizingFlexibleWidth)];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:1];
//create buttons
UIBarButtonItem* bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
//add buttons to the toolbar
[self.toolbar setItems:buttons animated:NO];
//add toolbar to the view
[self.view addSubview:self.toolbar];
//create UITableView
//a better way setting to set the frame!?!?
UITableView* listTable = [[UITableView alloc] initWithFrame:CGRectMake(0,
self.toolbar.bounds.size.height,
self.view.bounds.size.width,
self.view.bounds.size.height - self.toolbar.bounds.size.height)
style:UITableViewStylePlain];
[listTable setAutoresizesSubviews:TRUE];
[listTable setAutoresizingMask:(UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight)];
[listTable setDataSource:self];
[listTable setDelegate:self];
self.table = listTable;
[self.view addSubview:listTable];
}
在RootViewController的公司的loadView():
{
[super loadView];
controller = [[CustomViewController alloc] init];
[self.customView addSubview:controller.view];
[controller.view setAutoresizesSubviews:TRUE];
}
您可以在这里看到的截图: https://plus.google.com/u/0/photos/112841433450419935389/albums/5693241484889252817/5693241483569881554
我是新本,比获得正确的大小等,我在正确的轨道上?
非常感谢。
编辑:
我想创建这样
- 的UIViewController
- UINavigationBar的
- 的UIView < <左边的图,UIToolbar的自定义的UIViewController和UITableView
- 的UIView < <右侧,同上
这一个接近我想要不同的是,我将有两个的UITableView并没有分割按钮执行。 https://plus.google.com/u/0/photos/112841433450419935389/albums/5693241484889252817/5693260341279558818
Vince,请参阅上面的修改。我无法使用UINavigationController,因为我需要两个UITableView,并且每个人都有自己的工具栏。 – Eric 2012-01-03 04:50:59
@Eric,好的,从你的编辑中我发现你想把UIViewControllers放在其他的UIViewController中,除非你在使用UISplitViewController的iPad上,这会导致你麻烦。通常它是每个屏幕一个UIViewController。 – 2012-01-03 05:03:50