本文介绍了我只想在iPhone SDK的uiscrollview上实现放大功能,是否可以做到这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在iphone sdk的uiscrollview上实现放大功能.是否可以做到这一点?
I would like to implement only zoom in feature on uiscrollview in iphone sdk.Is it possible to do this?
我正在使用以下代码
{
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
And using uiscrollview delagte
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
return portrateSlideImage;
}
推荐答案
尝试一下.可能对您有帮助.
Try this. May be this would help you.
从要设置滚动视图最大比例的代码中删除该行
Remove the line from the code where you are setting maximum scale of scroll view
{
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
.只需放大
It won't allow you to zoom out
. Just zoom in
这篇关于我只想在iPhone SDK的uiscrollview上实现放大功能,是否可以做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!