iphone开发秘籍 - 监测晃动2种方法


方法1:

- (BOOL) canBecomeFirstResponder

{

    return YES;

}

- (void) viewDidAppear:(BOOL)animated

{

    [super viewDidAppear:animated];

    [self becomeFirstResponder];

}

- (void) viewWillDisappear:(BOOL)animated

{

    [super viewWillDisappear:animated];

    [self resignFirstResponder];

}

- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    NSLog(@"晃动了。。。。。");

}

方法2:

通过传感器移动监测晃动。

你可能感兴趣的:(iphone开发秘籍 - 监测晃动2种方法)