如何调整Scrollview中的图像大小?

时间:2013-11-01 01:09:19

标签: ios image uiscrollview resize image-size

我已经搜索了一段时间,但找不到任何特定于我的问题的内容。

基本上,我有一张大地图的图像,我希望用户能够放大和缩小,并滚动地图。我确实有缩放和滚动工作的所有方面,虽然当我启动应用程序时,图像(在滚动视图内)是巨大的!该图像是一个大文件(1200x1024),但它必须是这样,用户可以直接放大而没有任何像素化。

我的问题是,当我启动应用程序时,如何使图像(地图)适合屏幕的大小,然后从那里,用户可以放大和滚动等等?因为我启动时现在看起来像这样:http://i.stack.imgur.com/kq1en.png

谢谢你堆!

当前代码:(在' FireViewController.m'文件下)

@synthesize scrollView, imageView;

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ returnimageView;

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage     imageNamed:@"Mezzanine Level"]];
    self.imageView = tempImageView;

    scrollView.maximumZoomScale = 3.0;
    scrollView.minimumZoomScale = 0.3;
    scrollView.clipsToBounds = YES;
    scrollView.delegate = self;
   [scrollView addSubview:imageView];
   [scrollView setContentSize:imageView.frame.size];  
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

0 个答案:

没有答案
相关问题