DaffodilGirl 2013-03-15 01:58 采纳率: 0%
浏览 1970
已采纳

UIScrollView图片比较大

下面代码显示了scrollView,但是需要显示的图片(tutorial)比view大。
tutorial.png的尺寸是280X1200

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];
  • 写回答

1条回答

  • redCoral_ 2013-03-15 03:03
    关注

    试试:

    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];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制