这是我正在使用的代码:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 50, 70)];
[self.view addSubview:button];
if (buttonArray == nil) {
buttonArray = [[NSMutableArray alloc] init];
}
[buttonArray addObject:button];
[button release];
但是,没有显示对接。有什么想法吗?
答案 0 :(得分:8)
你错误地初始化了。请尝试以下方法:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 200, 50, 70);
[self.view addSubview:button];
if (buttonArray == nil) {
buttonArray = [[NSMutableArray alloc] init];
}
[buttonArray addObject:button];