在iPhone SDK 3.0之后,可以将initWithFrame用于自定义tableviewcell吗? [英] Is it ok to use initWithFrame for custom tableviewcell after iPhone SDK 3.0?

查看:41
本文介绍了在iPhone SDK 3.0之后,可以将initWithFrame用于自定义tableviewcell吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sdk3.0及更高版本中,已显示initWithFrame已被initWithStyle弃用.

It is shown that initWithFrame is deprecated with initWithStyle in sdk3.0 and above.

但是我们仍然可以在没有任何警告/错误的情况下使用它.那么可以继续使用initWithFrame在tableview中实现自定义单元格吗?

But we can still use it without any warning/error. So is it ok to continue using initWithFrame for implementing custom cell in tableview?

谢谢.

推荐答案

原则上可以.但是,新代码执行此操作实际上并没有任何意义.无论如何,传递给 initWithFrame 的帧实际上并不会影响该单元格,这意味着您应该只调用 initWithStyle:UITableViewCellStyleDefault ,其结果与 initWithFrame:相同:CGRectZero .

It is, in principle, ok. But it doesn't really make sense for new code to do this. The frame you pass to initWithFrame doesn't really influence the cell anyway, which means you should just call initWithStyle:UITableViewCellStyleDefault, which has the same result as initWithFrame:CGRectZero.

在现有代码中,当然可以继续使用 initWithFrame ,但是有机会的话,应该将其更改为 initWithStyle .将来某个时候(未知),Apple将停止支持不推荐使用的方法,并且如果使用旧方法,则您的应用程序将无法使用新的iPhone OS版本进行构建.

In existing code, it is of course ok for some time to keep using initWithFrame, but when you get the chance, you should change it to initWithStyle. At some (unknown) point in the future, Apple will stop supporting the deprecated method, and your app won't build with new iPhone OS releases if it uses old methods.

这篇关于在iPhone SDK 3.0之后,可以将initWithFrame用于自定义tableviewcell吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆