1
UIAccelerometer 값을 기준으로 scrollview를 스크롤하고 싶습니다. 가장 좋은 방법은 무엇입니까?UIAccelerometer 및 UIScrollView
내 주요 문제는 가속도계 값을 사용하여 콘텐츠 오프셋을 설정할 수 없다는 것입니다. scrollview 자체가 특정 속도로 스크롤되기 때문에 가속도계 값을 사용하여 스크롤하려고하면 저크가 발생합니다.
UIAccelerometer 값을 기준으로 scrollview를 스크롤하고 싶습니다. 가장 좋은 방법은 무엇입니까?UIAccelerometer 및 UIScrollView
내 주요 문제는 가속도계 값을 사용하여 콘텐츠 오프셋을 설정할 수 없다는 것입니다. scrollview 자체가 특정 속도로 스크롤되기 때문에 가속도계 값을 사용하여 스크롤하려고하면 저크가 발생합니다.
이 시도 :
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
if (sv.tracking || sv.decelerating) return;
CGPoint pt = sv.contentOffset;
pt.x += acceleration.x * 2;
pt.y -= acceleration.y * 2;
if (pt.x < 0) pt.x = 0;
if (pt.x > sv.contentSize.width - sv.frame.size.width) pt.x = sv.contentSize.width - sv.frame.size.width;
if (pt.y < 0) pt.y = 0;
if (pt.y > sv.contentSize.height - sv.frame.size.height) pt.y = sv.contentSize.height - sv.frame.size.height;
sv.contentOffset = pt;
}