【发布时间】:2014-08-05 06:25:25
【问题描述】:
我在缩放时遇到了一些问题,当我缩放时,下一个 UIImageView 超出了我正在放大的 UIImageView。
我将 UIImageView 加载到我在控制器中调用的 UIScrollView 的子类中。加载功能和滚动功能完美运行。
第一个问题是当我放大时,下一个 UIImageView 超出了我正在放大的那个。
所以我尝试将每个 UIImageView 放入我放入 ScrollView 的 UIView 中,但它执行相同的操作...
我遇到的第二个问题是,当我放大时,我的滚动不再起作用了。
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled=YES;
NSInteger numberOfViews = 6;
for (int i = 0; i < numberOfViews; i++) {
CGFloat xOrigin = i * self.view.frame.size.width;
image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d",i]]];
image.frame=CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:image];
}
scroll.maximumZoomScale=6.0;
scroll.minimumZoomScale=0.5;
scroll.delegate=self;
scroll.clipsToBounds=YES;
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height);
[self.view addSubview:scroll];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return image;
}
我知道存在与此类似的问题,但对我的事业没有任何帮助。任何对我的代码进行更改以使其正确的建议都非常感谢。
【问题讨论】:
-
在这里查看缩放和分页:raywenderlich.com/10518/…
-
@NeverHopeless 我已经感谢您的谷歌搜索。我没有使用分页,我使用的是单个 UIImageView
-
不使用分页,那为什么是
scroll.pagingEnabled = YES;?另外,当最小/最大缩放比例等于 1.0 时如何缩放? -
@NeverHopeless。抱歉,我的意思是说页面控制。我正在用不同的值测试缩放比例值。我编辑了代码。
-
@NeverHopeless 你知道答案吗??
标签: ios objective-c iphone uiscrollview uiimageview