0
美好的一天!我有一個表視圖,我想這樣設置表視圖高度:桌子的高度與變量
detailViewController = [[Contacts alloc] initWithNibName:@"Contacts" bundle:nil];
float height = 44*[[detailViewController contactList] count];
CGRect viewFrame = CGRectMake(0.0f, 50.0f, 250.0f, height);
[detailViewController.tableView setFrame: viewFrame];
MainViewController *mainView = (MainViewController*)app.viewController;
for (UIView *theView in mainView.currenWeatherView.subviews) {
[theView removeFromSuperview];
}
[mainView.currenWeatherView addSubview: detailViewController.tableView];
,但我不工作,高度是像一個屏幕或類似這樣的東西。
float height = 44*[[detailViewController contactList] count];
height = 10580;
出了什麼問題?
不知道你想達到什麼。通常你不會根據內容設置tableview的高度。您只需爲tableview設置固定框架並讓tableview管理其餘部分。 Tableview是scrollview的子類,所以如果你有更多的內容,tableview將滾動顯示其他單元格。 –