zoukankan      html  css  js  c++  java
  • UI_Target/action 设计模式

    RootView.m 中

        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(100, 100, 100, 40);
        [button setTitle:@"Target" forState:UIControlStateNormal];
        [self addSubview:button];
    
        // addTarget:self.controller 原来是 self
        // 方法 RootViewButtonDidClicked 在 ViewController.m 里面实现
        [button addTarget:self.controller action:@selector(RootViewButtonDidClicked:) forControlEvents:UIControlEventTouchUpInside];

    RootView.h 中

    设置属性

    @property (nonatomic, assign)UIViewController *controller;

    ViewController.m

    // 点击事件
    - (void)RootViewButtonDidClicked:(UIButton *)sender
    {
        NSLog(@"hello");
    }
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // 设置控制器
        self.rootView.controller = self;
    
    }
  • 相关阅读:
    从DataGridViewer导出Excel
    C#获取特定进程CPU和内存使用率
    51 nod 1265 四点共面
    51nod 1384 全排列
    51nod 2006 飞行员配对
    codeforces 839A
    codeforce 837C
    codeforces 837B
    codoforces 837A
    GIT
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5262048.html
Copyright © 2011-2022 走看看