我创建了一个类并命名为具有超类的示例UIview
。现在我想在我的班级中添加 UIButton
和UITextfield
,我已经动态创建但它不起作用。请检查下面的代码。
- (id)initWithFrame:(CGRect)frame
{
UIButton *but=[UIButton buttonWithType:UIButtonTypeRoundedRect];
but.frame= CGRectMake(200, 15, 15, 15);
[but setTitle:@"Ok" forState:UIControlStateNormal];
[but addTarget:self action:@selector(buttonAction)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:but];
self = [super initWithFrame:frame];
if (self)
{
// Initialization code
}
return self;
}
请帮忙。谢谢