And*_*rew 4 iphone objective-c uibutton
这是我正在使用的代码:
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];
Run Code Online (Sandbox Code Playgroud)
但是,对接没有显示出来.有什么想法吗?
你错误地初始化了.请尝试以下方法:
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];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2453 次 |
| 最近记录: |