與此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