UIScrollView 스크롤 방향을 얻는 방법입니다.
아래 코드는 테이블뷰를 아래로 스크롤 했을 때 특정 버튼이 보여지고 위로 스크롤 했을 때는 버튼을 숨기는 기능을 구현할 때 쓰입니다.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat yVelocity = [scrollView.panGestureRecognizer velocityInView:scrollView].y;
if (yVelocity < 0) {
NSLog(@"Up");
[writeBtn setHidden:YES];
} else if (yVelocity > 0) {
[writeBtn setHidden:NO];
NSLog(@"Down");
}
}
반응형
그리드형
'IT > iOS' 카테고리의 다른 글
[iOS] developer mode disabled 해결방법 (0) | 2023.07.27 |
---|---|
xcode7 bitcode 오류 (0) | 2015.09.18 |
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. (0) | 2015.09.18 |
[iOS] uiscrollview 스크롤시 맨위로 버튼 처리 (0) | 2015.08.13 |
x-apple-amd-action_message (13) | 2015.08.03 |
[iOS] UILabel random Textcolor (1) | 2015.07.14 |
[iOS] UIView 부분적으로 라운드 적용하기 (2) | 2015.05.19 |
[iOS] 앱평가 하기, 리뷰 남기기는 iRate로 (0) | 2015.03.30 |