我目前正在开发一款iPad应用,我需要一个“幻灯片”
所以我创建了第一个用作寻呼机的UIScrollView,在viewDidLoad中我使用“for”循环将内容放在UIScrollView中。
这是循环:
for (int i = 0; i < self.thumbs.count; i++) {
UIScrollView *subScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(self.ThumbsSlider.frame.size.width * i, 0, self.ThumbsSlider.frame.size.width, self.ThumbsSlider.frame.size.height)];
[subScroll setDelegate:self];
[subScroll setScrollEnabled:YES];
[subScroll setBouncesZoom:YES];
[subScroll setClipsToBounds:YES];
[subScroll setContentMode:UIViewContentModeCenter];
subviewImage = [[AsyncImageView alloc] initWithFrame:CGRectMake(0 , 0, subScroll.frame.size.width, subScroll.frame.size.height)];
subviewImage.contentMode = UIViewContentModeScaleAspectFit;
subviewImage.userInteractionEnabled = YES;
subviewImage.image = [UIImage imageNamed:@"no-image.jpg"];
subviewImage.imageURL = [NSURL URLWithString:[self.thumbs objectAtIndex:i]];
[subScroll addSubview:subviewImage];
subScroll.minimumZoomScale = 1.0;
subScroll.maximumZoomScale = 3.0;
[[subScroll delegate]viewForZoomingInScrollView:subScroll];
[self.ThumbsSlider addSubview:subScroll];
}
当我在iPad上启动应用程序时,没有崩溃。 但是,当我尝试缩放时,我的subScroll的contentSize会改变,但是subviewImage不会缩放!
有人能解释我为什么吗?
提前致谢!
答案 0 :(得分:1)
将此功能放入您的控制器
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
for (UIView *imageView in scrollView.subviews)
{
if ([imageView isKindOfClass:[AsyncImageView Class]])
{
return imageView;
}
}
return nil;
}
从循环中删除以下行:
[[subScroll delegate]viewForZoomingInScrollView:subScroll];