#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController {
IBOutlet UILabel *label_hello;
IBOutlet UIButton *button_iphone;
IBOutlet UIButton *button_ipad;
IBOutlet UIButton *button_ipodtouch;
IBOutlet UIImageView *image_bird;
IBOutlet UISlider *slider_alpha;
}
- (IBAction) button1Touched;
- (IBAction) button2Touched;
- (IBAction) button3Touched;
- (IBAction) sliderChanged;
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration; // 가속도 센서 프로토콜 등록
@property (nonatomic, retain) IBOutlet UILabel *label_hello;
@property (nonatomic, retain) IBOutlet UIButton *button_iphone;
@property (nonatomic, retain) IBOutlet UIButton *button_ipad;
@property (nonatomic, retain) IBOutlet UIButton *button_ipodtouch;
@property (nonatomic, retain) IBOutlet UIImageView *image_bird;
@property (nonatomic, retain) IBOutlet UISlider *slider_alpha;
@end
HelloWorldViewController.m
...
// 뷰 컨트롤러의 진입점
- (void) viewDidLoad{
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0/30)]; // 센서 업데이트 주기
[[UIAccelerometer sharedAccelerometer] setDelegate:self]; // 구현 클래스 지정
}
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ // 받아온 센서 값으로 구현
NSLog(@"UIAccelerometer = (%f,%f,%f)",acceleration.x,acceleration.y,acceleration.z);
}
...
? Shft+Cmd+R 을 누르면 Debugger Console 창이 나타난다.