2016-07-04 7 views
-1

동적 셀 수를 가진 tableview가 있습니다. 그리고 나는 tableview의 높이에 문제가 있습니다. tableview는 스크롤을하지만 마지막 셀까지 줄이지는 않습니다.하지만 tableview를 클릭하고 열심히 스크롤해야합니다. 클릭을 해제하면 다시 돌아옵니다. 여기tableView 동적 높이를 설정하는 방법?

내가 그것을

UIInterfaceOrientation newOrientation = [UIApplication sharedApplication].statusBarOrientation; 
if(newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight) 
{ 

    _logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width/2.3, self.view.bounds.size.height/3)]; 
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2.3, 0, self.view.bounds.size.width - self.view.bounds.size.width/2.3, self.view.bounds.size.height + self.view.bounds.size.height)]; 


} 

else if (newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown) 
{ 

    _logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height/4)]; 
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height/4, self.view.bounds.size.width, self.view.bounds.size.height)]; 
} 
imageView.frame = _logoView.bounds; 
[_logoView addSubview:imageView]; 


self.tableView.dataSource = self; 
self.tableView.delegate = self; 
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cells"]; 
[self.view addSubview:self.tableView]; 

를 구현하는 방법은 내가 초상화에있는 tableview의 높이에 다른 self.view.bounds.height를 추가 할 때있는 tableview의 GET의

+0

왜 vfl (autolayout)을 사용하지 않습니까? – Joshua

+0

그게 뭔가요? 그건 그렇고, 나는 동적으로 테이블 뷰를 만들고있다 – drbj

+0

시각 레이아웃 autolayout의 레이아웃. (https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html) @drbj – Joshua

답변

0

그것을 해결 작은. 내 잘못이야. 내 UITableView 높이가 초과합니다. 높이를 낮추면 제대로 작동합니다.

관련 문제