2014-09-29 3 views
0

몇 가지 다른 예를 보았지만 실제로 붙인 것은 아무것도 보지 못했습니다. 필자가 원하는 것은 본질적으로 tableViewHeader가하는 일입니다. 탐색 모음이있는 tableViewController가 있습니다. navbar 바로 아래 작은 막대에 몇 가지 검색 기준을 보여주는보기를 제자리에두고 싶습니다. 하지만 사용자가 결과를보기 위해 스 와이프 할 때 스틱을 사용해야합니다.탐색 막대 아래에 끈적한보기 추가

내비게이션 막대에 하위보기로 UIView를 추가하려고 시도했지만 항상 모든 항목을 오버레이하는 탐색 모음의 맨 위에 위치합니다.

+0

왜 상단 레이아웃 가이드를 사용하고 topLayoutGuide.bottom에 뷰의 상단을 설정하지? – CapturedTree

답변

2

은 일 무엇 :

// Create a custom navigation view 
    _navigationView = [[UIView alloc] init]; 
    _navigationView.backgroundColor = [UIColor whiteColor]; 
    _navigationView.frame = CGRectMake(0.0f, 
             self.navigationController.navigationBar.frame.origin.y + 44.0f, 
             self.view.frame.size.width, 
             30.0f); 

    // Create bottom border for the custom navigation view 
    _navigationViewBorder = [[UIView alloc] init]; 
    _navigationViewBorder.backgroundColor = [UIColor darkGrayColor]; 
    _navigationViewBorder.tag = 1; 
    _navigationViewBorder.frame = CGRectMake(0.0f, 
              self.navigationController.navigationBar.frame.origin.y + 74.0f, 
              self.view.frame.size.width, 
              0.5f); 

    // Add labels for date, results, and the time range 
    _dateDisplay = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 70, 15)]; 
    [_dateDisplay setFont:[UIFont fontWithName:@"HelveticaNeue" size:13]]; 
    [_dateDisplay setText:@""]; 

    _timeRangeDisplay = [[UILabel alloc] initWithFrame:CGRectMake(98, 0, 135, 15)]; 
    [_timeRangeDisplay setFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:13]]; 
    [_timeRangeDisplay setText:@""]; 

    _resultsDisplay = [[UILabel alloc] initWithFrame:CGRectMake(240, 0, 80, 15)]; 
    [_resultsDisplay setFont:[UIFont fontWithName:@"HelveticaNeue" size:13]]; 
    [_resultsDisplay setText:@""]; 

    [_navigationView addSubview: _dateDisplay]; 
    [_navigationView addSubview: _timeRangeDisplay]; 
    [_navigationView addSubview: _resultsDisplay]; 

    // Add two views to the navigation bar 
    [self.navigationController.navigationBar.superview insertSubview:_navigationView belowSubview:self.navigationController.navigationBar]; 
    [self.navigationController.navigationBar.superview insertSubview:_navigationViewBorder belowSubview:_navigationView]; 
1

viewController의 뷰에 뷰를 추가하고 해당 제약 조건을 설정하여 navigationBar 바로 아래에 있지만 tableView보다 위에 놓지 않는 이유는 무엇입니까?

일부 시간 만있는 경우 해당 제약 조건을 애니메이션으로 표시하거나 숨길 수 있습니다. 여기

+0

[self.view addSubview]를 통해 추가했지만 붙지 않았습니다. 이것은 tableViewController이기 때문에 가정합니다. ViewController가 아닌 tableViewController입니다. – jlrolin

+0

아, 그 세부 사항을 놓쳤습니다, 사과드립니다. UITableView 속성을 사용하여 UIViewController를 사용한다면 뷰 계층 구조에 대해 좀 더 제어 할 수 있습니다. UITableViewController를 사용하면 self.view가 실제로 tableView임을 확신 할 수 있습니다. 그래서 당신이 찾고있는 것을 얻기 위해 일반적인 UIViewController로 변환해야 할 수도 있습니다. –

+0

'tableView'에서'setContentInset'을 사용하여 아래로 이동 한 다음 테이블 뷰를 아래로 이동하여 필요한 여유 공간에 필요한 컨트롤이있는 뷰를 삽입 할 수 있습니다. – CapturedTree

관련 문제