0

より大きなuiscrollにネストされたuiscrollは、ズームされたときに、画面外にあるときにズームレベルをリセットする必要があります。スクロールが終了したときにすべてをリセットしようとしていますが、運がありません。何か案は?

myScrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
myScrollview.pagingEnabled = YES;
myScrollview.scrollEnabled =YES;
myScrollview.clipsToBounds = NO;
myScrollview.indicatorStyle = UIScrollViewIndicatorStyleWhite;
myScrollview.showsHorizontalScrollIndicator = YES;
myScrollview.backgroundColor = [UIColor blackColor];
myScrollview.delegate = self;

NSInteger viewcount=4;
NSArray *images = [NSArray arrayWithObjects:[UIImage imageNamed:@"01.png"],[UIImage imageNamed:@"02.png"],[UIImage imageNamed:@"03.png"],[UIImage imageNamed:@"04.png"],nil];

for (int i = 0; i <viewcount; i++)
{
    CGFloat x = i * self.view.frame.size.width;

    subView = [[UIScrollView alloc]initWithFrame:CGRectMake(x, 0, self.view.frame.size.width, self.view.frame.size.height)];

    [subView setBackgroundColor:[UIColor blackColor]];
    [subView setCanCancelContentTouches:NO];
    subView.clipsToBounds = NO;    // default is NO, we want to restrict drawing within our scrollview
    subView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    aImageView = [[UIImageView alloc ] initWithImage:[images objectAtIndex:i]];
    [self.aImageView setTag:viewcount];
    [subView addSubview:aImageView];
    [subView setContentSize:CGSizeMake(aImageView.frame.size.width, subView.frame.size.height)];
    subView.minimumZoomScale = 1;
    subView.maximumZoomScale = 3;
    subView.delegate = self;
    [subView setScrollEnabled:YES];
    subView.contentSize = aImageView.frame.size;
    [myScrollview addSubview:subView];
}

myScrollview.contentSize = CGSizeMake(self.view.frame.size.width*viewcount,self.view.frame.size.height);


[self.view addSubview:myScrollview];

}

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
NSLog (@"test");
UIView * view = nil;
view = [subView viewWithTag:0];
//return view;
return [scrollView.subviews objectAtIndex:0];  

}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"Did scroll");
[self resetImageZoom];

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {= NSLog(@ "Did end decal");

[self resetImageZoom];

}

-(void)resetImageZoom {NSLog(@ "画像ズームのリセット");

for(UIView *view in [myScrollview subviews]) {
    //if([view isKindOfClass:[UIScrollView class]]) {
    //[(UIScrollView*)view setZoomScale:1.0 animated:NO];
    //}
    view.transform = CGAffineTransformIdentity;
}

}

4

1 に答える 1

0

それはそれをしました...

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSLog(@"Did end dece");
for (UIView *view in scrollView.subviews) {
    if([view isKindOfClass:[UIScrollView class]]) {
        [(UIScrollView*)view setZoomScale:1.0 animated:NO];
    }
}

}

于 2012-07-24T21:24:26.070 に答える