,
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
IBOutlet UILabel *scoreLabel;
IBOutlet UILabel *timerLabel;
}
- (IBAction)buttonPressed;
@end
ViewController.m中的,
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)buttonPressed {
NSLog(@"Pressed!");
}
@end
我尝试将ViewController中的按钮连接到buttonPressed IBAction,方法是在按住Ctrl的同时单击按钮,然后在后台拖动它。我应该看到buttonPressed作为一个选项,但我没有看到它。怎么样?
答案 0 :(得分:1)
你可以在这里找到它(只需进入IB并在左栏选择你的控制器,然后进入右栏的最后一个标签):
然后您只需将其拖动到按钮并选择要呼叫的事件即可。