自我视图/超级视图
有什么区别
[self.view addSubview:view1];
和
[super.view addSubview:view1];
谢谢!!
弗兰胡
what's the difference between
[self.view addSubview:view1];
and
[super.view addSubview:view1];
Thank You!!
Franhu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您重写了
-view
方法,否则没有实际区别。不过,从语义差异来看,说super.view
是一种明确的尝试,以避免调用当前类中定义的名为-view
的方法。除非您想表达该含义,否则应该远离super.whatever
构造。Unless you've overridden the
-view
method, there is no practical difference. From a semantic difference, though, sayingsuper.view
is an express attempt to avoid invoking a method named-view
defined in the current class. Unless you want to express that meaning, you should stay away from thesuper.whatever
construct.由于视图是一种属性,因此归根结底并没有太大区别。
就我个人而言,我认为 self.view 更具可读性,并且据我所知是更常用的习惯用法。
Since view is a property, there isn't really much difference when it comes down to it.
Personally I think the self.view is more readable and is the more commonly used idiom as far as I know.