2012-11-01 2 views
1

나는 스토리 보드에 UITableView가있다.변경 uitableviewheader 높이

---------------------- 
| Button    | 
| Label    | 
---------------------- 

버튼이 조건이 충족되는 경우에만 나타납니다 다음있는 tableView이 같은 tableViewHeader을 가져옵니다. 버튼을 클릭하면 또한, 헤더는 다음과 같아야합니다 :

[UIView animateWithDuration:0.3 delay:0 options: UIViewAnimationCurveEaseOut 
        animations:^{ 
         self.tableView.contentOffset = CGPointMake(0, 59); 
        } 
        completion:^(BOOL finished) { 
         if (finished) { 
          self.tableView.contentOffset = CGPointMake(0, 59); 
          self.viewButton.hidden = YES; 
         } 
        } 
    ]; 

내가 버튼을 클릭하면이 좋은 작품 :

---------------------- 
| Label    | 
---------------------- 

내가 좋아하는 물건을 많이 했어요. 나는 또한 뷰 조작의 모든 종류의 시도처럼 tableViewHeader을 다시 시도

---------------------- 
|     | 
| Label    | 
---------------------- 

:처럼 표가보기 스크롤하지만, 일단은 0에서 반사 한 후 손실 오프셋, 내 테이블보기 보이는

---------------------- 
|     | 
|   Label | 
---------------------- 

내가 UIViewController에 내 문제에 대한 내있는 UITableViewController 변경에 대한 뭔가를 보았다는보기 제어 방식을 조작하여 해결 될 것입니다 :

CGRect frame = self.tableView.tableHeaderView.frame; 
frame.size.height = 31; 
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:frame]; 
[self.tableView.tableHeaderView addSubview:self.viewTitle]; 

결과를 얻기 oller 프레임,하지만 난 10 테이블보기처럼하고 정말 필요한 모든 변경을 할 시간이 없어.

제발 도와 줄 수 있습니까?

답변

0

내부에있는 UITableView와 함께 UIViewController를 사용하기로 결정했습니다. 여기 내 조언은 : UITableViewController에 대해 잊어 버려라. 그것은 엉망입니다. 이 솔루션은 다음과 같습니다

버튼 :

- (IBAction)synchronizeTouchUpInside:(id)sender { 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.3]; 
    self.view.frame = CGRectMake(0, -59, 320, 367 + 59); 
    [UIView commitAnimations]; 

} 

viewWillAppear :

- (void)viewWillAppear:(BOOL)animated { 

    if (1 == 1) { 
     self.view.frame = CGRectMake(0, -59, 320, 367 + 59); 
    } else { 
     self.view.frame = CGRectMake(0, 0, 320, 367); 
    } 

} 

지금 난 그냥 테이블 뷰 컨트롤러의 많은 재 구축 할 필요가있다. C'est la vie. 해당 테이블 헤더보기가 이미 할당하기 전에 크기를 조정해야

self.tableView.tableHeaderView = self.tableView.tableHeaderView; 

참고 :

0

그냥 복사/붙여 넣기 문제인지 모르겠지만 헤더 프레임을 변경하면 단계가 누락되었다고 생각합니다. 이와 시도 : 마지막 할당을 생략하면

CGRect frame = self.tableView.tableHeaderView.frame; 
frame.size.height = 31; 
self.tableView.tableHeaderView.frame = frame; 

, 당신은 단지 로컬 CGRect를 생성하고 그 값을 수정 한, 실제로 헤더의 프레임을 변경했습니다.

+0

'self.tableView.tableHeaderView.frame = frame'은 제약 조건 충돌을 일으 킵니다. 이를 해결하기 위해 새 프레임을 할당하려고했습니다. – lolol

+0

정확한 오류 메시지를 게시 할 수 있습니까? – sergio

+0

제약 조건을 동시에 충족시킬 수 없습니다. UIView : 0x8d77fd0.bottom == UIView : 0x8d767e0.bottom을 위반하여 복구를 시도합니다. objc_exception_throw를 중단하십시오. – lolol

5

나는 테이블 뷰의 헤더에 동일한 개체를 다시 할당하여 해결 유사한 문제를 얻었다.