使用UIScrollView滚动UIImage

用户名

我正在尝试让我的图片成为panzoomable,但是我似乎无法使其正常工作。

这是我的注释代码>创建UIScrollView>创建PFImageViewUIImage)>将图像添加到UIScrollView>提取并显示图像。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"%@",_courseObject);                         //checking object has loaded

    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.frame = self.view.bounds;                //scroll view occupies full parent view!
    scrollView.contentSize = CGSizeMake(400, 800);      //scroll view size
    scrollView.showsVerticalScrollIndicator = YES;      //to hide scroll indicators!
    scrollView.showsHorizontalScrollIndicator = YES;    //by default, it shows!
    scrollView.scrollEnabled = YES;                     //say "NO" to disable scroll
    [self.view addSubview:scrollView];                  //adding to parent view!



    PFImageView *mapImage = [[PFImageView alloc] init];         //create imageview
    mapImage.frame = self.navigationController.view.frame;      //set image boundaries to fill nav frame(!)
    mapImage.image = [UIImage imageNamed:@"loading"];           //placeholder image
    mapImage.file = (PFFile *)[_courseObject objectForKey:@"file"]; //retrieve the map image

    [scrollView addSubview:mapImage];                               //add the mapImage to scrollView
    [mapImage loadInBackground];                                    //retrieve image and add

}
用户名

这里的问题是,scrollView.contentSize不够大,因此在尝试滚动时并不能吸收运动。

更改值以填充框架并实现委托协议,使我可以使用滚动视图。

UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章