因此,我一直在努力学习针对iOS的Objective-C编程的基础知识。现在我需要在框架中放置一个简单的按钮以及一个标签。我得到了标签工作,但我不知道按钮代码有什么问题。iOS在viewcontroller.m中添加一个按钮
代码:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(25, 25, 275, 60)];
label.text = test;//@"I am learning Objective-C for the\n very first time!";
label.numberOfLines = 0;
label.lineBreakMode = UILineBreakModeWordWrap;
//label.lineBreakMode = NSLineBreakByWordWrapping; //iOS 6 only
[self.view addSubview:label];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(25, 100, 275, 40)];
button.titleLabel.text = @"Hello";
[self.view addSubview:button];
按钮没有显示出来......
什么问题? – rmaddy
@rmaddy该按钮不会显示...? – user115422
小贴士:如果视图不会出于未知原因,请尝试设置'view.backgroundColor = [UIColor redColor]'。 – DrummerB