예, 오프셋을 -50.0으로 제한 할 수 있습니다.
- (void) observeValueForKeyPath:(NSString*)keyPath
ofObject:(id)object
change:(NSDictionary*)change
context:(void*)context
{
//if this is not the only KVO then you should first perform some checks
//if the object and keypath are correct
//otherwise you can omit the check or modify, if your UIScrollView is subclassed
if ([object isKindOfClass:[UIScrollView class]])
{
UIScrollView *scrl = (UIScrollView *)object;
CGPoint offset = scrl.contentOffset;
if (offset.y < -50.0f)
{
offset.y = -50.0f;
scrl.contentOffset = offset;
}
}
}
당신은 KVO는 훌륭한 도구입니다. scrollView
대리자 메서드 (didScroll:
다른 사람이 코드를 이동하는 것을 고려 할 수 있습니다하지만 빠르게 변화하는 값을 너무 비용이 많이들 수 있습니다. 응답에 대한
감사하지만 불행히도 scrollview의 contentOffset 속성을 설정해도 사용자가 스크롤 할 수있는 것처럼 스크롤 뷰를 만들지는 못합니다. 그냥 시도해 보았습니다. –
흠, 어쩌면 당신을 잘못 이해했기 때문에 scrollView를 계속 스크롤하는 것처럼 그의 손가락?이 경우 나는'touchesEnabled'를'y'가 -50.0에 이르렀을 때'NO'로 설정하려고 시도 하겠지만, 'didEndScrollingAnimation' 델리게이트 메소드를 구현하기 위해서, 당신은'scrollView'에 대한 접촉을 다시 가능하게 할 것입니다 : 나는 모든 행동 관련 코드를'delegate' 메소드로 옮기고이 특별한 경우에 KVO를 버릴 것입니다. –