如果我将子类UIButton
并使用它的buttonWithType:
方法创建button
,它会返回一个UIButton
或子类实例吗?UIButton子类:是否buttonWithType:返回UIButton或子类实例?
例如:
@interface MyButton : UIButton
@end
MyButton *button = [MyButton buttonWithType:UIButtonTypeCustom];
或者我必须使用alloc
和initWithFrame
呢?
感谢
它应该像对UIButton一样进行正常的初始化,你只需要继承UIButton类,这意味着你的类实现了父类的所有行为,你也可以添加额外的功能,并且可以像使用方式一样使用你为简单的UIButton做,但你必须定义类的按钮,而不是UIButton * myButton;你必须编写MyButton * myButton;而已。 – iphonic 2013-03-14 08:07:20