若使用 nib ,使用 registerNib:注册,dequeue 时会调用 cell 的 -(void)awakeFromNib


不使用 nib ,使用 registerClass: 注册, dequeue时会调用 cell 的 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

#pragma mark - 重写初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    return self;

当你使用 SDAutoLayout 对一个 UIImageView 进行宽高布局的时候,会出现与 CornerRadius 冲突的情况。

- (UIImageView *)userAvatarImageView{
    if (!_userAvatarImageView) {
        _userAvatarImageView = [[UIImageView alloc]init];
        _userAvatarImageView.layer.cornerRadius = _userAvatarImageView.frame.size.width / 2;
        _userAvatarImageView.layer.masksToBounds = YES;//enable imageView to take effect
    return _userAvatarImageView;

因为 SDAutoLayout 进行了宽高布局,导致圆角失效。

.topSpaceToView(self.contentView, 12)
.leftSpaceToView(self.contentView, 12)
.widthIs(self.frame.size.height - 2 * 12)//因为在这里进行了宽高设置
.heightIs(self.frame.size.height - 2 * 12);

解决方案:调用 sd_cornerRadiusFromHeightRatio 的 getter 方法进行设置

self.userAvatarImageView.sd_cornerRadiusFromHeightRatio = @(0.5); //解决头像不是圆角的 BUG

假设我们需要达成的需求:在 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。