So, I’ve been trying to learn the basics of Objective-C programming for iOS. Now I need to have a simple button placed in the frame along with a label. I got the label working but I’m not sure what’s wrong with the button code.
The code:
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];
The button isn’t showing up…
A typical way to create a button is this:
Then the
someMeothod:would be: