3

Okay, I have been all over the internet trying to find the answer to this, I am trying to create a custom UIScrollView scroller.

Here is a link to a picture of the scroller

http://postimage.org/image/cg2jvde9z/

http://postimage.org/image/ko0mp3kdj/ (that white box is just for me to test the scrollview)

I have gotten the scroller to work, although I need help figuring out how many pixels the scrollview should move every time the scroller is pushed

here is some code

-(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];


    }
}

}

In the above code you should see a '(Help HERE!)',

that is where i am trying to figure out how many pixels i should move the scroll view. This is a bit of a confusing question, hope you understand.

Thanks :)

4

1 回答 1

1

我不知道 APPLE 是否会批准这一点,但下面编写的代码可以更改 scollView 的滚动图像

for (UIImageView *img in yourscrollView.subviews) { 
    [img setImage:[UIImage imageNamed:@"your custom scroller image"]];
}
于 2012-06-14T07:31:59.260 回答