假设我们需要达成的需求:在 View 文件中包含一个 UIButton 控件且包含 selector 方法,需求:在 Controller 中对其调用。


  • SpecificView.h & SpecificView.m
  • UIViewController.h & UIViewController.m


  • 通过暴露属性的方式来达到目的(这里就不谈了,自行百度
  • 采用代理模式。代理模式用大白话说就是:委托方让代理方代替自己执行一定的动作


首先,在 SpecificView.h 中声明 Delegate 代理:

@protocol ScuserLoginContainerDelegate <NSObject>
- (void)onBtnClick:(UIButton *)sender;
@interface SpecificView : UIView
@property (nonatomic, weak)id<ScuserLoginContainerDelegate> delegate;

Delegate 的声明方法如下:

@protocol 协议名称 <NSObject>
- (void)协议方法;

注意:在这里,务必使用 weak 修饰符,防止出现“循环引用”。

@propery (nonatomic, weak)id<协议名称> delegate;

然后,在 SpecificView.m 中实现相关方法:

@interface SpecificView ()
@property (strong, nonatomic) UIButton *myBtn;


@implementation MyView
- (id)initWithFrame:(CGRect)frame
    self = [super initWithFrame:frame];
    if (self)
        _myBtn = [[UIButton alloc] initWithFrame:CGRectMake(140, 100, 100, 50)];
        _myBtn.backgroundColor = [UIColor redColor];
        [_myBtn addTarget:self
                   action:@selector(myBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_myBtn];
    return self;
// view 中按钮的事件
- (void)myBtnClick:(UIButton *)btn
    NSLog(@"Method in view");
    if ( [self.delegate respondsToSelector:@selector(onBtnClick:)] )
        [self.delegate onBtnClick:btn];
        NSLog(@"BtnClick: haven't found in delegate.");

接着,在 UIViewController.m 中遵循协议,创建 SpecificView 对象并且设置代理为 self ,在这里即是 UIViewController 。

SpecificView *container = [[SpecificView alloc]initWithFrame:self.view.bounds];
container.delegate = self;


- (void)onBtnClick:(UIButton *)sender{
    //TODO 完成点击按钮后的方法

总结:采用代理模式能够实现 view 和 controller 之间的解耦。这是因为由于按钮事件是在 view 中绑定的,而不是在 controller 中绑定的,因此使用该 view 的类只需要实现相应的代理方法就可以定制按钮点击后的事件了,这也更加方便了 view 的复用,体现了 view 与 controller 解耦合的优势。




Nowadays, people often give the thumbs-up or forward without distinguishing right from wrong on social media. From my perspective, the practice is premature and wise.
In recent years, more and more celebrities have encountered online violence and suffered from depression, leading to committing suicide. For example, a twenty-year-old actor named MR. Qiao quitted his young life because of netizen's false comment. It is people's unwise behavior that causes such a tragedy. If people can think twice before they give the thumbs-up or forward, I believe such events can be avoided.
As a citizen in the Internet age, the number one priority should be given to tell right from wrong. We should take other's feelings and thoughts into account and improve our personal quality on the Internet. As we all know, sometimes gossip is the most horrible killer, which harms our mental health. What's more, we should care about own life as well as others'.
To sum up, not only should we prevent ourselves from giving the thumbs-up or forward blindly, but we also should remind others of their wrong behavior.


In an era of Internet, more and more people now prefer to give the thumbs-up and forward without a second thought or confirming whether what they have seen is true or not. I would like to put forward my opinions on that.
The material mentioned above provides a deep insight into the current online issues and i am lost in my thought about my own experience. When I first stepped into the online world years ago, I was fascinated by various kinds of information and stories online. Soon I formed a habit of giving the thumbs-up and forward whatever I had seen or read, which eventually led to my confusion about what on earth is important and genuine.
I'm inclined to consider this phenomenon meaningless, I strongly recommend that we should always think twice when surfing the Internet. I hold the firm belief that, more than often, the online world is stuffed with gossip and fake news. Only by recognizing them with our deep insight and wisdom can we be spared from the fate of being tricked by the Internet. What's more, having a clear mind can help us develop our ability to distinguish right from wrong.
To conclude, I sincerely hope that everyone should be alert to the information online and careful when giving the thumbs-up. Let's resist the present trend and be a rational person.




  1. 将订单页面更改成奖单页面
  2. 奖单页面采用全新设计:移动导航栏;移动导航栏分为两个一级菜单:“已中签”以及“进行中”。
  3. 首页的控制器也改成移动导航栏,七个同级菜单:周一到周日;对应的ViewController显示一个抽签按钮、一个所抽物品图片、以及开奖时间和剩余下签人数。
  4. 在“我的页面”将“我的钱包”改成“我的会员”



  • 《用户协议》重写,避免雷区。
  • 《隐私政策》重写,避免雷区。
  • 在用户进行一切操作前,必须同意所有协议。
  • 为了保证抽奖结果的有效性和真实性,用户必须提供个人信息证明。《隐私协议》中涉及我们不会将个人信息泄漏等相关条例,避免相关雷区,防止踩雷,不让上架AppStore。




  • 进行了例行公事,总结了2017年,发布了第一份年末总结报告《2017年末总结报告》
  • 同月,编写了基于LUA语言的微信《跳一跳》小程序的自动刷分脚本。


  • 未知,浑浑噩噩过了这一个月


  • 买了一套自认为很搭配的衣服、手机壳、手表(三位一体


  • 这段时间一直在我家附近的球场打夜球,打球打球还是打球。BTW,音速3又便宜又耐用。


  • 成年了,终于满18岁了。
  • iPhone 6s还是寿终正寝了,陪我了两年的6s因为屏幕漏液等一系列问题进入半死亡状态。


  • 整个七月上旬,拿出了乔帮主参与设计的最后一款产品——iPhone5,刷机到iOS6,勉勉强强能用。
  • 咸鱼淘二手,淘到了一部iPhone 7 32G 磨砂黑,感觉还行。



  • 穿衣风格好像有点偏离了正确轨道,可能是抖音看多了吧(笑
  • 烫了一个逗号刘海?我也不知道,不知道脑子怎么想的。


  • 参加我学校举办的运动会,担任摄影师工作,同时也遇到了一个装腔作势的女孩子(从来想到一个女孩子还能这样装


  • 花了4800,将自己的iPhone 7更换成了一部二手美版iPhone X
  • 卖了SIGMA 18-35mm F1.8的单反镜头,把买iPhone X的钱填上了
  • 11月下旬,和一个出国的朋友——飞总合作,创建第一个商业项目:本物-iOS;飞总是CEO,我是CTO,各掌权50%。
  • 本月份的月考,考到了年级87名的成绩,仍在不断努力。


  • 12月初,二手手机果然不是很可靠啊,iPhone X出现无故断电现象,找卖家,卖家答应给我换了。
  • 12月中旬,拿到了更换后的iPhone X,就是电池循环效率有点低,比起之前那部问题机,电池循环率只有90%(苦笑
  • 12月下旬,前往上海环球贸易中心IAMPGenius Bar,天才吧工作人员很乐意的给我换了(保外换电池RMB 214
  • 12/31日,和朋友们跨过了2018年。
  • 本月份浦东新区的一模考试,校内成绩为年级58名,距离目标年级前20仍需要继续努力!