【问题标题】:iphone viewForZoomingInScrollView not callediphone viewForZoomingInScrollView 未调用
【发布时间】:2013-02-10 15:11:47
【问题描述】:

编辑:我有包含 uiscrollview 的控制器。该滚动视图包含自定义 uiview,其单独的类继承自 uiview。那个 uiview 有 uiimageview 作为子视图。不,我在主控制器中使用“(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView”。但是当我缩放滚动视图时,该方法没有被触发。我应该怎么做才能调用这个方法。

UIView *DrawingPlusImageView = [[UIView alloc]initWithFrame:CGRectMake((i*IMAGEVIEW_IPAD_LAND_X+112), 0, 800, 600)];

    IDDrawingView *drawView = [[IDDrawingView alloc]initWithFrame:CGRectMake(0, 0, 800, 600)];

    UIImageView* imgViewLand = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)];
    [imgViewLand setImage:[UIImage imageNamed:@"noFileSelected.png"]];
    [drawView setImageToDraw:imgViewLand.image];
    //        drawView.delegate = self;
    [drawView setCurrentSlidId:hmslide.strSlideID];
    [DrawingPlusImageView addSubview:imgViewLand];
    [DrawingPlusImageView addSubview:drawView];


    [scrollViewPresentation addSubview:DrawingPlusImageView];
    drawView.userInteractionEnabled = YES;

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
// Return the view that we want to zoom

return  [self.scrollViewPresentation.subviews objectAtIndex:1];// there are slides, im zooming the second
}

【问题讨论】:

    标签: iphone ipad uiscrollview


    【解决方案1】:

    我遇到了同样的问题。并为 ScrollView 设置最小和最大缩放级别解决了我的问题..try

    self. scrollViewPresentation.minimumZoomScale = 1.0;
    self. scrollViewPresentation.maximumZoomScale = 10.0;
    

    【讨论】:

      【解决方案2】:

      只有在您开始缩放时才会调用它。视图应该是滚动视图的子视图,保留对它的引用作为属性并在委托方法中返回:

      - (void)viewDidLoad
      {
          [super viewDidLoad];
      
          [self.view addSubview:self.scrollView];
          [self.scrollView addSubview:self.container];
          [self.container addSubview:self.imageView];
      }
      
      - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
      {
          return self.imageView;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-13
        • 2012-10-03
        • 1970-01-01
        • 2011-07-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多