2016-03-28 17 views
-2

Bir görünümü çekmece olarak oluşturdum. UITableview içerir. UITableview'i aşağı sürüklediğimde, görünüm kaybolacak ve UITableview öğesinin contentoffset.y hala 0 olacaktır; scrollViewDidScroll'da UITableview çerçevesini değiştirdim ve scrollViewDidEndDragging öğesini değiştirdim ve animasyon UITableview öğesinin ardından UITableview öğesinin tıklatıldığında hücrenin seçili olmamasına ancak VerticalScrollIndicator'ın gizlendiğine ve bu UITableview'ın normal duruma getirilmesinin ardından sürüklenmeye başladığını gördüm.uitableview, bitmiş görüntüyü sürüklerken hala VerticalScrollIndicator'ı gösterir

- (void)moveWithOffset:(CGFloat)offset { 

CGFloat searchBarTop = _searchBar.top; 
    self.height = SCREEN_HEIGHT-NavBar_HEIGHT; 
    if (offset > 0) { 
     if (GestureViewHeight - _searchBar.top > 0.1) { 
      _gestureView.hidden = YES; 
      searchBarTop = (_searchBar.top+offset) < GestureViewHeight ? (_searchBar.top+offset) : GestureViewHeight; 
     } else { 
      _gestureView.hidden = NO; 
      if (self.top < SCREEN_HEIGHT/2) { 
       self.top = (self.top+offset) < SCREEN_HEIGHT/2 ? (self.top+offset) : SCREEN_HEIGHT/2; 
      } 
     } 
    } else if (offset < 0) { 
     if (self.top - NavBar_HEIGHT > 0.1) { 
      _gestureView.hidden = NO; 
      self.top = (self.top+offset) > 64 ? (self.top+offset) : 64; 
      searchBarTop = GestureViewHeight; 
     } else { 
      _gestureView.hidden = YES; 
      if (searchBarTop > 0) { 
       searchBarTop = (_searchBar.top+offset) > 0 ? (_searchBar.top+offset) : 0; 
      } 
     } 
    } 

[self adjustLayoutWithSearchBarTop:searchBarTop]; 

}

- (void)endMoving { 
if ((int)self.top == NavBar_HEIGHT) { 
    _state = ALDHotScenicSpotSearchViewStateUp; 
} else if ((int)self.top == SCREEN_HEIGHT*2/3) { 
    _state = ALDHotScenicSpotSearchViewStateMiddle; 
} else if ((int)self.top == SCREEN_HEIGHT/2) { 
    _state = ALDHotScenicSpotSearchViewStateDown; 
} else { 
    if (self.top < SCREEN_HEIGHT/3 && _state != ALDHotScenicSpotSearchViewStateUp) { 
     _state = ALDHotScenicSpotSearchViewStateUp; 
    } else if (self.top > SCREEN_HEIGHT/3 && _state != ALDHotScenicSpotSearchViewStateDown) { 
     _state = ALDHotScenicSpotSearchViewStateDown; 
    } else { 
     _state = ALDHotScenicSpotSearchViewStateMiddle; 
    } 
} 
[self animatingToState:_state]; 

}

- (void)animatingToState:(ALDHotScenicSpotSearchViewState)state { 
switch (state) { 
    case ALDHotScenicSpotSearchViewStateUp: 
    { 
     [UIView animateWithDuration:0.3 animations:^{ 
      self.frame = CGRectMake(0, NavBar_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT-NavBar_HEIGHT); 
      _gestureView.hidden = YES; 
      [self adjustLayoutWithSearchBarTop:0]; 
     }]; 
    } 
     break; 
    case ALDHotScenicSpotSearchViewStateDown: 
    { 
     [UIView animateWithDuration:0.3 animations:^{ 
      self.frame = CGRectMake(0, SCREEN_HEIGHT/2, SCREEN_WIDTH, SCREEN_HEIGHT/2); 
      _gestureView.hidden = NO; 
      [self adjustLayoutWithSearchBarTop:GestureViewHeight]; 
     }]; 
    } 
     break; 
    case ALDHotScenicSpotSearchViewStateMiddle: 
    { 
     [UIView animateWithDuration:0.3 animations:^{ 
      self.frame = CGRectMake(0, SCREEN_HEIGHT/3, SCREEN_WIDTH, SCREEN_HEIGHT*2/3); 
      _gestureView.hidden = NO; 
      [self adjustLayoutWithSearchBarTop:GestureViewHeight]; 
     }]; 
    } 
     break; 

    default: 
     break; 
} 

}

- (void)adjustLayoutWithSearchBarTop:(CGFloat)top { 
self.frame = CGRectMake(0, self.top, self.width, SCREEN_HEIGHT-self.top); 
_searchBar.frame = CGRectMake(0, top, self.width, 44); 
_tableView.frame = CGRectMake(0, _searchBar.bottom, self.width, self.height-_searchBar.bottom); 

}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 
if (_isSwiping) { 
    _isSwiping = NO; 
    [self endMoving]; 

} 

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
if (scrollView.contentOffset.y < 0 && !scrollView.isDecelerating && (int)_searchBar.top == 0) { 
    _isSwiping = YES; 
} 
if (_isSwiping) { 
    [self moveWithOffset:-scrollView.contentOffset.y]; 
    scrollView.contentOffset = CGPointMake(0, 0); 
} 

}

+0

Bu yalnızca masaüstünü hızlıca aşağı sürüklediğimde, yavaşça sürüklendiğinde olur – Brazen

cevap

0

[_tableView setContentOffset: CGPointMake (0, -1) animasyon: EVET]; [_tableView setContentOffset: CGPointMake (0, 0) hareketli: YES]; işlevine ekleLayoutWithSearchBarTop sorunu çözecektir. reasom belki de scrollview.isdragging scrollViewDidEndDragging içinde gerçek kalıyor.