我已经定义了一个 uiscrollview 并使用一个 for 循环向它添加按钮,但是每当我运行程序时,我都会出现一个空白屏幕。这是我的 viewDidLoad,这是我与此相关的所有代码。
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 1000)];
scrollView.hidden = NO;
names = [[NSMutableArray alloc]initWithObjects:@"Excavations",@"Concrete",@"Framing",@"Insulation",@"Drywall",@"Finish Carpentry",@"Paint",@"Electrical",@"HVAC",@"Plumbing",@"Roofing",@"Tile",@"Doors",@"Windows",@"Flooring",@"Countertops",@"Landscape",@"Hardscape", nil];
for (int i = 0; i < 18; i++) {
UIButton *button = [[UIButton alloc]init];
button.frame = CGRectMake(0, 50*i, 320, 50);
button.tag = i;
[button addTarget:self action:@selector(NewView:) forControlEvents:UIControlEventTouchUpInside];
button.titleLabel.text = [names objectAtIndex:i];
button.hidden= NO;
[scrollView addSubview:button];
}
// Do any additional setup after loading the view, typically from a nib.
}