3
好吧,我已經遍及互聯網試圖找到答案,我正在嘗試創建一個自定義的UIScrollView滾動器。創建一個自定義的UIScrollView Scroller
這裏是一個滾輪
http://postimage.org/image/cg2jvde9z/
http://postimage.org/image/ko0mp3kdj/ 的圖片的鏈接(即白盒只是對我來說,測試滾動型)
我已經得到了滾輪的工作,儘管我需要幫助確定滾動視圖每次滾動滾動條時應移動多少像素
這裏是一些代碼
-(IBAction)scroller_bar:(id)sender withEvent:(UIEvent *)event{
UIButton *button_sent = (UIButton *)sender;
UITouch *touch = [[event touchesForView:button_sent] anyObject];
CGPoint previousLocation = [touch previousLocationInView:button_sent];
CGPoint location = [touch locationInView:button_sent];
CGFloat delta_x = location.x - previousLocation.x;
float left_side = button_sent.center.x + delta_x;
float right_side = button_sent.center.x + delta_x;
if (right_side > button_sent.center.x) {
scroll_right = YES;
}
else{
scroll_right = NO;
}
if (left_side <= 13 + 50.5 || right_side >= 307 - 50.5) {
}
else{
button_sent.center = CGPointMake(button_sent.center.x + delta_x,
button_sent.center.y);
if (scroll_right) {
[selection_scroll setContentOffset:CGPointMake(selection_scroll.contentOffset.x - (Help HERE!), selection_scroll.contentOffset.y) animated:YES];
}
else{
[selection_scroll setContentOffset:CGPointMake(selection_scroll.contentOffset.x + (Help HERE!), selection_scroll.contentOffset.y) animated:YES];
}
}
}
在上面的代碼,你會看到一個「(幫助在這裏!)」,
這正是我試圖找出有多少像素的,我應該移動滾動視圖。這是一個令人困惑的問題,希望你能理解。
謝謝:)
是啊,我不希望蘋果拒絕正因爲如此,這就是爲什麼我創造了我自己的。不過謝謝 – Jacob