【问题标题】:UIScrollView with Large Image带有大图像的 UIScrollView
【发布时间】:2013-03-03 14:48:15
【问题描述】:

此代码显示滚动视图,但我想要显示的图像(教程)大于视图。换句话说,tutorial.png 正好是 280X1200,但它不会有 aspectFit。我在这里遗漏了一些小东西:

tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)];
tipScroll.showsVerticalScrollIndicator = YES;
tipScroll.scrollEnabled = YES;
tipScroll.userInteractionEnabled = YES;

UIImageView *tutorialImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tutorial"]];

tipScroll.contentMode = UIViewContentModeScaleAspectFit;
tutorialImageView.contentMode = UIViewContentModeScaleAspectFit;

tipScroll.contentSize = tutorialImageView.frame.size;

[self.view addSubview:tipScroll];
[tipScroll addSubview:tutorialImageView];

【问题讨论】:

    标签: iphone uiview uiscrollview uiimageview


    【解决方案1】:

    请看下面的编辑代码。它会工作

    tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)];
    tipScroll.showsVerticalScrollIndicator = YES;
    tipScroll.scrollEnabled = YES;
    tipScroll.userInteractionEnabled = YES;
    
    UIImageView *tutorialImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 280, 1200)];
    tutorialImageView.image = [UIImage imageNamed:@"tutorial"];
    
    tipScroll.contentSize = tutorialImageView.frame.size;
    [tipScroll addSubview:tutorialImageView];
    [self.view addSubview:tipScroll];
    

    【讨论】:

      猜你喜欢
      • 2011-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 1970-01-01
      相关资源
      最近更新 更多