zoukankan      html  css  js  c++  java
  • 在滚动视图里添加图像视图,在图像视图里添加按钮控件

     》》点击按钮“Button”》》》》

    绿底的是一张图片(1.png),截自苹果文档。

    第一个视图对应VC1:

    VC1

     1 @synthesize scrollView = _scrollView;
     2 
     3 - (void)viewDidLoad
     4 {
     5     [super viewDidLoad];
     6     
     7     // 配置 UIImageView 对象
     8     UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];
     9     imgView.userInteractionEnabled = YES;  // UIImageView 的 userInteractionEnabled 属性默认 "NO",因此默认情况下,添加在 UIImageView 中的 UIButton 将不发生触摸事件
    10     
    11     // 配置并添加 UIButton 对象
    12     UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    13     button.frame = CGRectMake(100, 80, 50, 60);
    14     [button setTitle:@"Button" forState:UIControlStateNormal];
    15     [button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    16     [imgView addSubview:button];
    17     
    18     // 添加 UIImageView 对象
    19     [self.scrollView addSubview:imgView];
    20     
    21     // 配置 UIScrollView 对象
    22     self.scrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
    23     self.scrollView.scrollEnabled = YES;
    24     self.scrollView.clipsToBounds = YES;
    25     self.scrollView.contentSize = CGSizeMake(imgView.frame.size.width, imgView.frame.size.height);
    26     
    27 }
    28 
    29 - (IBAction)button:(id)sender
    30 {
    31     [self performSegueWithIdentifier:@"SeguePush1" sender:self];
    32 }

     。 


    /**************************************************************************
                      原文来自博客园——Submarinex的博客: www.cnblogs.com/submarinex/               
      *************************************************************************/

  • 相关阅读:
    f12 接口自动刷新页面 来不及看接口信息 前端有没有传值
    order by 分组报错 shop 有三个字段 根据author 选出最大的price
    mybatis 动态sql
    正则 只有英文或者数字 长度6位以上 数字或者英文全部一样
    sql :1 :2
    前端Json数据,后台String接收,如何解析
    Json数据格式化
    LeetCode63. 不同路径 II
    LeetCode62. 不同路径
    LeetCode746. 使用最小花费爬楼梯
  • 原文地址:https://www.cnblogs.com/submarinex/p/2802015.html
Copyright © 2011-2022 走看看