我试图做出一个操作,每次按下按钮时,都会向视图添加一个按钮。我没有尝试过的作品。从IBAction以编程方式添加UIButton
如果有人能够清理该做什么,这将是非常感谢。
这是在我的按钮添加按钮的最近一次尝试:
-(IBAction) addButton{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(10,10,50,50);
button.tag = 1;
[button addTarget:self
action:@selector(buttonTouched:)
forControlEvents:UIControlEventTouchUpInside];
[view addSubview:button];
}
您确定调用该方法吗? – Alexander 2012-03-29 04:53:39
检查IBAction是否正确接线。有时赶时间,我们错过了绑定动作/ iboutlets ... – 2012-03-29 04:56:10
还要确保'view'不是'nil'。 – Costique 2012-03-29 05:04:24