Reputation: 69
I have no idea how I can get stuck on this simple thing, but I can't get my button to change my label. What have I missed?
FirstViewController.h:
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *quoteButton;
@property (weak, nonatomic) IBOutlet UILabel *quoteLabel;
@end
FirstViewController.m:
#import "FirstViewController.h"
@implementation FirstViewController
#pragma mark - User Interaction
- (IBAction)quoteButtonPressed {
self.quoteLabel.text = @"Hello World";
}
@end
Upvotes: 0
Views: 70
Reputation: 517
I think it's a problem of a connection between button and function try to click CTRL and drag the button to the function code to link them
Upvotes: 1
Reputation: 1
Whether quoteButtonPressed: method is executed. You can try to make a breakpoint at the line of -(void)quoteButtonPressed: method. Then you run the project again, see Whether the project stops at the breakpoint line.
Did IBOutlet connect well? There is any warnings about connections.
Lengthen quoteLabel.
Upvotes: 0
Reputation: 162
you may not connect IBAction for button.or IBOutlet connection for label to interface builder.check it
Upvotes: 1