Tap UIButton to create another UIButton programmatically
我正在尝试以编程方式创建uibutton。我有一个名为"addcash"的按钮(它已经在Interface Builder中创建),点击这个按钮后,我希望另一个按钮动态显示。当在viewdidload中完成时,这个按钮可以正常工作,但这不是我想要的"addcash",在创建这个新按钮之前需要点击。这就是我迄今为止所拥有的…
1 2 3 4 5 6 7 8 9 | -(IBAction) addCash{ UIButton *theButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; theButton.frame = CGRectMake(80, 50, 150, 40); [theButton setTitle:@"title" forState:UIControlStateNormal]; [theButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside]; [theButton setBackgroundImage:[UIImage imageNamed:@"edit.jpg"] forState:UIControlStateNormal]; [self.view addSubview:theButton]; } |
如果要添加大量按钮,请在自定义单元格中使用