UIScrollView私の問題を説明する前に、非常に基本的な質問ですが、このメソッドからオブジェクトを返す方法はありますか
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
今私の問題は、その中にscrollview複数の子を持つ親があるscrollviewことです(すべて水平およびページングが有効になっています)。
各子scrollviewにはImageView. サーバーからファクターを取得しており、にzoomScale基づいてズームする必要があります。問題は、内部にある子をimageズームしようとすると、最後の子のみがズームされることです。scrollViewimagescrollview
scrollviewですから、上記のデリゲートからフォームを返す方法を見つける必要があると思います。
これを解決する方法を知っている人はいますか?
これはUIViewクラスであり、これにscrollViewとimageを追加し、scrollView DelegateのimageViewを返しました
サンプルコード:
     - (id)initWithFrame:(CGRect)frame image:(UIImage *)image
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor yellowColor];      
        self.imageView = [[UIImageView alloc] initWithImage:image];
        self.imageView.tag = VIEW_FOR_ZOOM_TAG;
        self.imageView.frame=frame;//CGRectMake(8,8 ,305, 400);
        [self.imageView setContentMode:UIViewContentModeScaleAspectFit];
        self.scrollView = [[UIScrollView alloc] initWithFrame:frame];
        self.scrollView.minimumZoomScale = 0.4f;
        self.scrollView.maximumZoomScale = 2.0f;
        self.scrollView.backgroundColor=[UIColor redColor];
        self.scrollView.zoomScale = 1.0f;
        self.scrollView.contentSize = self.imageView.bounds.size;
        self.scrollView.delegate = self;
        self.scrollView.showsHorizontalScrollIndicator = NO;
        self.scrollView.showsVerticalScrollIndicator = NO;
        [self.scrollView setCanCancelContentTouches:NO];
        [self.scrollView addSubview:self.imageView];
        [self addSubview:self.scrollView];
        NSLog(@"ScrollViewPostion %f",self.scrollView.frame.origin.x);
    }
    return self;
}
#pragma -mark
#pragma -mark ScrollViewDelegates
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return [scrollView viewWithTag:VIEW_FOR_ZOOM_TAG];
}
そして、メインのviewControllerクラスでこれを行っていますが、スクロールビューにすべての画像を適切に追加していません
 NSLog(@"Inner scrollFrame and content size %f %f",innerScrollFrame.origin.x,mainScrollView.contentSize.width);
    JoinSeeSubView *subView=[[JoinSeeSubView alloc] initWithFrame:innerScrollFrame image:img];
    [self.mainScrollView addSubview:subView];
        if (i < [self.allUrlArray count]-1) {
            innerScrollFrame.origin.x += innerScrollFrame.size.width;
    }
    i++;
    mainScrollView.contentSize = CGSizeMake(innerScrollFrame.origin.x + innerScrollFrame.size.width, mainScrollView.bounds.size.height);