DWQA QuestionsCategory: ProgramA class inherits uiview and calls the init method. Why does this init method call the initwithframe method I override?
Cass asked 4 months ago

A class inherits uiview and calls the init method. Why does this init method call the initwithframe method I override? Is this because the init method calls this method by default?

QTDetailsFooterView *footerView = [[QTDetailsFooterView alloc]init];

  • (instancetype)initWithFrame:(CGRect)frame;
1 Answers
AngryLi answered 4 months ago

View created with pure code will call initwithframe when init. Even if init method is used for initialization, initwithframe will also be called, but the frame parameter is cgrectzero. The inirwithcoder is called when the view created with Xib and storyboard is initialized. The principle is the same as above.

Cass replied 4 months ago

Do you have any books to recommend? There seems to be no information available. The description in the code is initialization by default, but I’m not sure. I really feel your professional reply.

AngryLi replied 4 months ago

Look at this blog. Can you understand it(http://blog.sina.com.cn/s/blog_5eadd29401011hzj.html),If you have any doubts, you can try and continue to communicate.

Cass replied 4 months ago

well. Thank you.