0

我想只在 iphone sdk 的 uiscrollview 上实现放大功能。可以这样做吗?

我正在使用下面的代码

{
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 700, 510)];
   scrollView.delegate = self;
   scrollView.ScrollEnabled=YES;
   scrollView.contentSize = CGSizeMake(700, 510);
   scrollView.userInteractionEnabled = FALSE;
   scrollView.clipsToBounds = YES;
   scrollView.minimumZoomScale = 1;
   scrollView.maximumZoomScale = 2;
   [scrollView addSubview:portrateSlideImage];
   [portSlideContainer addSubview:scrollView];

}

并使用 uiscrollview delagte

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return portrateSlideImage;
}
4

1 回答 1

0

尝试这个。可能这会对你有所帮助。

从代码中删除设置滚动视图最大比例的行

{
   scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 700, 510)];
   scrollView.delegate = self;
   scrollView.ScrollEnabled=YES;
   scrollView.contentSize = CGSizeMake(700, 510);
   scrollView.userInteractionEnabled = TRUE;         //edited again
   scrollView.clipsToBounds = YES;
   scrollView.minimumZoomScale = 1;
   scrollView.maximumZoomScale = 2;                  //edited again
   [scrollView addSubview:portrateSlideImage];
   [portSlideContainer addSubview:scrollView];
}

并添加此功能

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
   scrollView.minimumZoomScale = scale;
}

它不允许你这样做zoom out。只是放大

于 2012-07-18T08:05:16.113 回答