2
後,谷歌網頁我試着打電話給谷歌網頁後搖iPhone.i試過這樣如何調用抖動
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(event.type == UIEventSubtypeMotionShake)
{
[self shakemethod];
[self open];
}
}
-(void)shakemethod
{
CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"];
[shake setDuration:1.1];
[shake setRepeatCount:2];
[shake setAutoreverses:YES];
[shake setFromValue:[NSValue valueWithCGPoint:
CGPointMake(lockImage.center.x - 15,lockImage.center.y)]];
[shake setToValue:[NSValue valueWithCGPoint:
CGPointMake(lockImage.center.x + 15, lockImage.center.y)]];
[lockImage.layer addAnimation:shake forKey:@"position"];
}
-(void)open
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://google.co.in"]];
}
兩種方法的工作,但是當我搖晃iPhone晃動的圖像不顯示谷歌網頁打開 所以請但是幫助我。我需要當我搖動手機第一次搖動圖像,搖晃完畢後搖晃打開Google頁面。
感謝高級。
感謝您的重播 – 2014-10-07 12:38:37